-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added the account settings page, which was forgotten.
- Loading branch information
Huludini
committed
Feb 17, 2016
1 parent
683dd12
commit 4e11c81
Showing
7 changed files
with
210 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
<?php | ||
|
||
namespace App\Http\Controllers\Front; | ||
|
||
use App\UserInfo; | ||
use Illuminate\Http\Request; | ||
|
||
use App\Http\Requests; | ||
use App\Http\Controllers\Controller; | ||
use Illuminate\Support\Facades\Auth; | ||
use Illuminate\Support\Facades\DB; | ||
use Illuminate\Support\Facades\Hash; | ||
|
||
class AccountController extends Controller | ||
{ | ||
/** | ||
* AccountController constructor. | ||
*/ | ||
public function __construct() | ||
{ | ||
$this->middleware( 'auth' ); | ||
} | ||
|
||
/** | ||
* Show the account settings page | ||
* | ||
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View | ||
*/ | ||
public function getSettings() | ||
{ | ||
pagetitle( [ trans( 'main.settings' ), settings( 'server_name' ) ] ); | ||
return view( 'front.account.index' ); | ||
} | ||
|
||
/** | ||
* Save the user's new password | ||
* | ||
* @param Request $request | ||
* @return $this|\Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector | ||
*/ | ||
public function postPassword( Request $request ) | ||
{ | ||
$this->validate($request, [ | ||
'current_password' => 'required|current_pass|max:255', | ||
'new_password' => 'required|confirmed|min:6' | ||
]); | ||
|
||
$user = Auth::user(); | ||
$user->password = Hash::make( $request->new_password ); | ||
$user->save(); | ||
|
||
DB::connection('account') | ||
->table('accounts') | ||
->where('id', $user->id) | ||
->update(['password' => $request->new_password]); | ||
|
||
DB::connection('member') | ||
->table('tb_user') | ||
->where('idnum', $user->id) | ||
->update([ | ||
'password' => $request->new_password, | ||
'pwd' => Hash::make( $request->new_password ) | ||
]); | ||
|
||
flash()->success( trans( 'main.settings_saved' ) ); | ||
return redirect( 'account/settings#password' ); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<?php | ||
|
||
namespace App\Providers; | ||
|
||
use Illuminate\Support\Facades\Auth; | ||
use Illuminate\Support\Facades\Hash; | ||
use Illuminate\Support\Facades\Validator; | ||
use Illuminate\Support\ServiceProvider; | ||
|
||
class CustomValidation extends ServiceProvider | ||
{ | ||
/** | ||
* Bootstrap the application services. | ||
* | ||
* @return void | ||
*/ | ||
public function boot() | ||
{ | ||
Validator::extend('current_pass', function($attribute, $value, $parameters, $validator) { | ||
$user = Auth::user(); | ||
if ( Hash::make( $value ) !== $user->password ) | ||
{ | ||
return FALSE; | ||
} | ||
return TRUE; | ||
}); | ||
} | ||
|
||
/** | ||
* Register the application services. | ||
* | ||
* @return void | ||
*/ | ||
public function register() | ||
{ | ||
// | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
@extends( 'front.header' ) | ||
|
||
@section( 'content' ) | ||
<div class="portlet light"> | ||
<div class="portlet-body"> | ||
<div class="tabbable-custom nav-justified"> | ||
<ul class="nav nav-tabs nav-justified"> | ||
<li class="active"> | ||
<a href="#overview" data-toggle="tab"> <i class="icon-speedometer"></i> {{ trans( 'main.acc_tabs.overview.title' ) }} </a> | ||
</li> | ||
<li> | ||
<a href="#password" data-toggle="tab"> <i class="icon-lock"></i> {{ trans( 'main.acc_tabs.password.title' ) }} </a> | ||
</li> | ||
</ul> | ||
<div class="tab-content"> | ||
<div class="tab-pane active" id="overview"> | ||
<div class="portlet-body form"> | ||
<div class="row"> | ||
<div class="col-md-12"> | ||
<form role="form" class="form-horizontal"> | ||
<div class="form-body"> | ||
<div class="col-md-6"> | ||
<div class="form-group form-md-line-input"> | ||
<label class="col-md-3 control-label" for="form_control_1">{{ trans( 'main.acc_tabs.overview.fields.name' ) }}</label> | ||
<div class="col-md-9"> | ||
<div class="form-control form-control-static"> {{ Auth::user()->username }} </div> | ||
<div class="form-control-focus"> </div> | ||
</div> | ||
</div> | ||
</div> | ||
<div class="col-md-6"> | ||
<div class="form-group form-md-line-input"> | ||
<label class="col-md-3 control-label" for="form_control_1">{{ trans( 'main.acc_tabs.overview.fields.password' ) }}</label> | ||
<div class="col-md-9"> | ||
<div class="form-control form-control-static"> ******** </div> | ||
<div class="form-control-focus"> </div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</form> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
<div class="tab-pane" id="password"> | ||
<div class="portlet light"> | ||
<div class="portlet-body form"> | ||
<form action="{{ url( 'account/settings/password' ) }}" method="post" class="form-horizontal"> | ||
{!! csrf_field() !!} | ||
<div class="form-body"> | ||
<div class="form-group form-md-line-input"> | ||
<label class="col-md-3 control-label" for="current_password">{{ trans( 'main.acc_tabs.password.fields.current' ) }}</label> | ||
<div class="col-md-9"> | ||
<input name="current_password" type="password" class="form-control" id="current_password"> | ||
<div class="form-control-focus"> </div> | ||
<span class="help-block">{{ trans( 'main.acc_tabs.password.fields.current_desc' ) }}</span> | ||
</div> | ||
</div> | ||
<div class="form-group form-md-line-input"> | ||
<label class="col-md-3 control-label" for="new_password">{{ trans( 'main.acc_tabs.password.fields.new' ) }}</label> | ||
<div class="col-md-9"> | ||
<input name="new_password" type="password" class="form-control" id="new_password"> | ||
<div class="form-control-focus"> </div> | ||
</div> | ||
</div> | ||
<div class="form-group form-md-line-input"> | ||
<label class="col-md-3 control-label" for="new_password_confirmation">{{ trans( 'main.acc_tabs.password.fields.confirm' ) }}</label> | ||
<div class="col-md-9"> | ||
<input name="new_password_confirmation" type="password" class="form-control" id="new_password_confirmation"> | ||
<div class="form-control-focus"> </div> | ||
</div> | ||
</div> | ||
</div> | ||
<div class="form-actions"> | ||
<div class="row"> | ||
<div class="col-md-offset-2 col-md-9"> | ||
<button type="submit" class="btn green">{{ trans( 'main.save' ) }}</button> | ||
</div> | ||
</div> | ||
</div> | ||
</form> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
@endsection |