Skip to content

Commit 2d57772

Browse files
committed
Migrate ability to reset passwords
1 parent f47f0cd commit 2d57772

File tree

7 files changed

+131
-0
lines changed

7 files changed

+131
-0
lines changed

app/Http/Controllers/Auth/PasswordController.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ class PasswordController extends Controller
1919
*/
2020

2121
use ResetsPasswords;
22+
protected $redirectTo = '/';
2223

2324
/**
2425
* Create a new password controller instance.

app/Http/Routes/AuthRoutes.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,14 @@ public function map(Router $router) {
1111
$router->get('login', [ 'as' => 'auth.login', 'uses' => 'Auth\AuthController@getLogin' ]);
1212
$router->post('login', [ 'as' => 'auth.login.submit', 'uses' => 'Auth\AuthController@postLogin' ]);
1313

14+
$router->get('password', [ 'as' => 'auth.password', 'uses' => 'Auth\PasswordController@getEmail' ]);
15+
$router->post('password', [ 'as' => 'auth.password.submit', 'uses' => 'Auth\PasswordController@postEmail' ], function () {
16+
return redirect('auth/password')->with('sent', true);
17+
});
18+
19+
$router->get('password/verify/{token}', [ 'as' => 'auth.verify', 'uses' => 'Auth\PasswordController@getReset' ]);
20+
$router->post('password/verify', [ 'as' => 'auth.verify.submit', 'uses' => 'Auth\PasswordController@postReset' ]);
21+
1422
$router->get('logout', [ 'as' => 'auth.logout', 'uses' => 'Auth\AuthController@getLogout' ]);
1523
});
1624
}

resources/lang/en/auth.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@
1717
'throttle' => 'Too many login attempts. Please try again in :seconds seconds.',
1818
'errorencountered' => 'There was an error encountered while attempting to process this request.',
1919
'resetpassword' => 'Reset Password',
20+
'confirmpassword' => 'Confirm Password',
21+
'sendlink' => 'Send Password Reset Link',
22+
'emailsent' => 'Your password reset email is on its way.',
2023
'remeberme' => 'Remeber Me',
2124

2225
];

resources/lang/en/strings.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
'password' => 'Password',
1313
'email' => 'Email',
1414
'whoops' => 'Whoops',
15+
'success' => 'Success',
1516
'location' => 'Location',
1617
'node' => 'Node',
1718
'connection' => 'Connection',
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
@extends('layouts.master')
2+
3+
@section('title', 'Reset Password')
4+
5+
6+
@section('right-nav')
7+
@endsection
8+
9+
@section('sidebar')
10+
@endsection
11+
12+
@section('content')
13+
<div class="col-md-6">
14+
<form action="/auth/password" method="POST">
15+
<legend>{{ trans('auth.resetpassword') }}</legend>
16+
<fieldset>
17+
@if (count($errors) > 0)
18+
<div class="alert alert-danger">
19+
<strong>{{ trans('strings.whoops') }}!</strong> {{ trans('auth.errorencountered') }}<br><br>
20+
<ul>
21+
@foreach ($errors->all() as $error)
22+
<li>{{ $error }}</li>
23+
@endforeach
24+
</ul>
25+
</div>
26+
@endif
27+
@if (session('status'))
28+
<div class="alert alert-success">
29+
<strong>{{ trans('strings.success') }}!</strong> {{ trans('auth.emailsent') }}
30+
</div>
31+
@endif
32+
<div class="form-group">
33+
<label for="email" class="control-label">{{ trans('strings.email') }}</label>
34+
<div>
35+
<input type="text" class="form-control" name="email" id="email" value="{{ old('email') }}" placeholder="{{ trans('strings.email') }}" />
36+
</div>
37+
</div>
38+
<div class="form-group">
39+
<div>
40+
{!! csrf_field() !!}
41+
<button class="btn btn-default btn-sm">{{ trans('auth.sendlink') }}</button>
42+
</div>
43+
</div>
44+
</fieldset>
45+
</form>
46+
</div>
47+
<div class="col-md-3"></div>
48+
@endsection
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
@extends('layouts.master')
2+
3+
@section('title', 'Reset Password')
4+
5+
6+
@section('right-nav')
7+
@endsection
8+
9+
@section('sidebar')
10+
@endsection
11+
12+
@section('content')
13+
<div class="col-md-6">
14+
<form action="/auth/password/verify" method="POST">
15+
<legend>{{ trans('auth.resetpassword') }}</legend>
16+
<fieldset>
17+
@if (count($errors) > 0)
18+
<div class="alert alert-danger">
19+
<strong>{{ trans('strings.whoops') }}!</strong> {{ trans('auth.errorencountered') }}<br><br>
20+
<ul>
21+
@foreach ($errors->all() as $error)
22+
<li>{{ $error }}</li>
23+
@endforeach
24+
</ul>
25+
</div>
26+
@endif
27+
<input type="hidden" name="token" value="{{ $token }}">
28+
<div class="form-group">
29+
<label for="email" class="control-label">{{ trans('strings.email') }}</label>
30+
<div>
31+
<input type="text" class="form-control" name="email" id="email" value="{{ old('email') }}" placeholder="{{ trans('strings.email') }}" />
32+
</div>
33+
</div>
34+
<div class="form-group">
35+
<label for="password" class="control-label">{{ trans('strings.password') }}</label>
36+
<div>
37+
<input type="password" class="form-control" name="password" id="password" placeholder="{{ trans('strings.password') }}" />
38+
</div>
39+
</div>
40+
<div class="form-group">
41+
<label for="password_confirmation" class="control-label">{{ trans('auth.confirmpassword') }}</label>
42+
<div>
43+
<input type="password" class="form-control" id="password_confirmation" name="password_confirmation" />
44+
</div>
45+
</div>
46+
<div class="form-group">
47+
<div>
48+
{!! csrf_field() !!}
49+
<button class="btn btn-primary btn-sm">{{ trans('auth.resetpassword') }}</button>
50+
</div>
51+
</div>
52+
</fieldset>
53+
</form>
54+
</div>
55+
<div class="col-md-3"></div>
56+
@endsection
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
2+
<html>
3+
<head>
4+
<title>Pterodactyl Lost Password Recovery</title>
5+
</head>
6+
<body>
7+
<center><h1>Pterodactyl Lost Password Recovery</h1></center>
8+
<p>Hello there! You are receiving this email because you requested a new password for your Pterodactyl account.</p>
9+
<p>Please click the link below to confirm that you wish to change your password. If you did not make this request, or do not wish to continue simply ignore this email and nothing will happen. <strong>This link will expire in 1 hour.</strong></p>
10+
<p><a href="{{ url('auth/password/verify/'.$token) }}">{{ url('auth/password/verify/'.$token) }}</a></p>
11+
<p>Please do not hesitate to contact us if you belive something is wrong.
12+
<p>Thanks!<br />Pterodactyl</p>
13+
</body>
14+
</html>

0 commit comments

Comments
 (0)