Skip to content

Commit

Permalink
Adding Change Password page for admins
Browse files Browse the repository at this point in the history
  • Loading branch information
MinePoS Dedicated committed Jul 6, 2018
1 parent 63b2df2 commit 3e92dac
Show file tree
Hide file tree
Showing 5 changed files with 84 additions and 2 deletions.
30 changes: 30 additions & 0 deletions app/Http/Controllers/Admin/Dashboard.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,34 @@ public function dd(){
$json_string = json_encode(Request("commands"));
die($json_string);
}

public function showChangePassword(){
return view('admin.pages.account.changepassword');
}


public function doChangePassword(){
if (Hash::check(\Request('current_password'), \Auth::user()->password)) {
$new1 = \Request('new_password');
$new2 = \Request('new_password_repeat');
if($new1 == $new2){
$u = \Auth::user();
$u->password = \Hash::make($new1);
$u->save();
session()->flash('good', 'Password Changed!');
return redirect()->route('admin.account.changepassword');
}else{
session()->flash('bad', 'Passwords did not match');
return redirect()->route('admin.account.changepassword');
}
}else{
session()->flash('bad', 'Incorrect password');
return redirect()->route('admin.account.changepassword');
}


return view('admin.pages.account.changepassword');
}


}
2 changes: 1 addition & 1 deletion config/self-update.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
|
*/

'version_installed' => env('SELF_UPDATER_VERSION_INSTALLED', '0.0.5'),
'version_installed' => env('SELF_UPDATER_VERSION_INSTALLED', '0.0.6'),

/*
|--------------------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion resources/views/admin/layout.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@
<!-- Menu Footer-->
<li class="user-footer">
<div class="pull-left">
<a href="#" class="btn btn-default btn-flat">Profile</a>
<a href="{{Route('admin.account.changepassword')}}" class="btn btn-default btn-flat">Profile</a>
</div>
<div class="pull-right">
<a href="{{Route('logout')}}" class="btn btn-default btn-flat">Sign out</a>
Expand Down
48 changes: 48 additions & 0 deletions resources/views/admin/pages/account/changepassword.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
@extends('admin.layout')

@section('title')
Change Password
@endsection

@section('desc')
Changing your password is always a good idea
@endsection

@section('content')

<div class="col-md-12">
<!-- general form elements -->
<div class="box box-primary">
<div class="box-header with-border">
<h3 class="box-title">Change Password</h3>
</div>
<!-- /.box-header -->
<!-- form start -->
<form role="form" action="{{route('admin.account.changepassword')}}" method="POST">
{{csrf_field()}}
<div class="box-body">
<div class="form-group">
<label for="current_password">Current Password</label>
<input class="form-control" autocomplete="off" name="current_password" id="current_password" type="password" required>
</div>
<div class="form-group">
<label for="new_password">New Password</label>
<input class="form-control" name="new_password" id="new_password" type="password" required>
</div>
<div class="form-group">
<label for="new_password_repeat">New Password Repeat</label>
<input class="form-control" name="new_password_repeat" id="new_password_repeat" type="password" required>
</div>


</div>
<!-- /.box-body -->

<div class="box-footer">
<button type="submit" class="btn btn-primary">Create</button>
</div>
</form>
</div>
<!-- /.box -->
</div>
@endsection
4 changes: 4 additions & 0 deletions routes/admin/web.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
Route::get('register', 'Auth\RegisterController@showRegistrationForm')->name('register');
Route::post('register', 'Auth\RegisterController@register');

Route::get('change-password','Admin\Dashboard@showChangePassword')->name('admin.account.changepassword');
Route::post('change-password','Admin\Dashboard@doChangePassword')->name('admin.account.changepassword');


// Password Reset Routes...
Route::get('password/reset', 'Auth\ForgotPasswordController@showLinkRequestForm')->name('password.request');
Route::post('password/email', 'Auth\ForgotPasswordController@sendResetLinkEmail')->name('password.email');
Expand Down

0 comments on commit 3e92dac

Please sign in to comment.