Password Reset work

This commit is contained in:
Deon George 2020-01-22 21:05:31 +11:00
parent b42f9990b5
commit 436c3d6787
10 changed files with 72 additions and 62 deletions

View File

@ -32,13 +32,13 @@ before_script:
# Add gnupg & zip # Add gnupg & zip
- apt-get update -yqq && apt-get install gnupg2 unzip -yqq - apt-get update -yqq && apt-get install gnupg2 unzip -yqq
# Upgrade to Node 9 # Upgrade to Node 12
- curl -sL https://deb.nodesource.com/setup_9.x | bash - - curl -sL https://deb.nodesource.com/setup_12.x | bash -
# Install dependencies # Install dependencies
#- apt-get install git nodejs libcurl4-gnutls-dev libicu-dev libmcrypt-dev libvpx-dev libjpeg-dev libpng-dev libxpm-dev zlib1g-dev libfreetype6-dev libxml2-dev libexpat1-dev libbz2-dev libgmp3-dev libldap2-dev unixodbc-dev libpq-dev libsqlite3-dev libaspell-dev libsnmp-dev libpcre3-dev libtidy-dev pkg-config libsnmp-dev snmp-mibs-downloader -yqq #- apt-get install git nodejs libcurl4-gnutls-dev libicu-dev libmcrypt-dev libvpx-dev libjpeg-dev libpng-dev libxpm-dev zlib1g-dev libfreetype6-dev libxml2-dev libexpat1-dev libbz2-dev libgmp3-dev libldap2-dev unixodbc-dev libpq-dev libsqlite3-dev libaspell-dev libsnmp-dev libpcre3-dev libtidy-dev pkg-config libsnmp-dev snmp-mibs-downloader -yqq
#- download-mibs #- download-mibs
- apt-get install git nodejs -yqq - apt-get install git autoconf nodejs -yqq
# Install php extensions # Install php extensions
#- docker-php-ext-configure gd --with-freetype-dir=/usr/include/freetype2 --with-jpeg-dir=/usr/include/ #- docker-php-ext-configure gd --with-freetype-dir=/usr/include/freetype2 --with-jpeg-dir=/usr/include/

View File

@ -20,16 +20,6 @@ class ForgotPasswordController extends Controller
use SendsPasswordResetEmails; use SendsPasswordResetEmails;
/**
* Create a new controller instance.
*
* @return void
*/
public function __construct()
{
$this->middleware('guest');
}
public function showLinkRequestForm() public function showLinkRequestForm()
{ {
return view('adminlte::auth.passwords.email'); return view('adminlte::auth.passwords.email');

View File

@ -2,10 +2,12 @@
namespace App\Http\Controllers\Auth; namespace App\Http\Controllers\Auth;
use App\Http\Controllers\Controller;
use Illuminate\Foundation\Auth\ResetsPasswords; use Illuminate\Foundation\Auth\ResetsPasswords;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use App\Providers\RouteServiceProvider;
class ResetPasswordController extends Controller class ResetPasswordController extends Controller
{ {
/* /*
@ -26,26 +28,8 @@ class ResetPasswordController extends Controller
* *
* @var string * @var string
*/ */
protected $redirectTo = '/home'; protected $redirectTo = RouteServiceProvider::HOME;
/**
* Create a new controller instance.
*
* @return void
*/
public function __construct()
{
$this->middleware('guest');
}
protected function rules()
{
return [
'token' => 'required',
'email' => 'required|email|exists:users',
'password' => 'required|confirmed|min:6',
];
}
public function showResetForm(Request $request, $token = null) public function showResetForm(Request $request, $token = null)
{ {
return view('adminlte::auth.passwords.reset')->with( return view('adminlte::auth.passwords.reset')->with(

View File

@ -11,11 +11,24 @@ class ResetPasswordNotification extends Notification
{ {
use Queueable; use Queueable;
/**
* The password reset token.
*
* @var string
*/
public $token; public $token;
/** /**
* Create a new notification instance. * The callback that should be used to build the mail message.
* *
* @var \Closure|null
*/
public static $toMailCallback;
/**
* Create a notification instance.
*
* @param string $token
* @return void * @return void
*/ */
public function __construct($token) public function __construct($token)
@ -24,10 +37,10 @@ class ResetPasswordNotification extends Notification
} }
/** /**
* Get the notification's delivery channels. * Get the notification's channels.
* *
* @param mixed $notifiable * @param mixed $notifiable
* @return array * @return array|string
*/ */
public function via($notifiable) public function via($notifiable)
{ {
@ -35,18 +48,33 @@ class ResetPasswordNotification extends Notification
} }
/** /**
* Get the mail representation of the notification. * Build the mail representation of the notification.
* *
* @param mixed $notifiable * @param mixed $notifiable
* @return \Illuminate\Notifications\Messages\MailMessage * @return \Illuminate\Notifications\Messages\MailMessage
*/ */
public function toMail($notifiable) public function toMail($notifiable)
{ {
$logo = config('SITE_SETUP')->site_logo; if (static::$toMailCallback) {
$site_name = config('SITE_SETUP')->site_name; return call_user_func(static::$toMailCallback, $notifiable, $this->token);
$reset_link = route('password.reset', $this->token, true); }
return (new MailMessage) return (new MailMessage)
->markdown('email.user.passwordreset',compact('logo','site_name','reset_link')); ->markdown('email.user.passwordreset',[
'site'=>config('SITE_SETUP'),
'user'=>$notifiable,
'reset_link'=>route('password.reset',$this->token,true),
]);
}
/**
* Set a callback that should be used when building the notification mail message.
*
* @param \Closure $callback
* @return void
*/
public static function toMailUsing($callback)
{
static::$toMailCallback = $callback;
} }
} }

6
composer.lock generated
View File

@ -2336,11 +2336,11 @@
}, },
{ {
"name": "leenooks/laravel", "name": "leenooks/laravel",
"version": "6.0.13", "version": "6.0.14",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://dev.leenooks.net/leenooks/laravel", "url": "https://dev.leenooks.net/leenooks/laravel",
"reference": "62f66d7eedaa4e86595965e146fb1cf3e9c341d8" "reference": "176f680ff740d41b6e66723557e2e64721e0d51f"
}, },
"require": { "require": {
"creativeorange/gravatar": "^1.0", "creativeorange/gravatar": "^1.0",
@ -2377,7 +2377,7 @@
"laravel", "laravel",
"leenooks" "leenooks"
], ],
"time": "2020-01-14T10:43:40+00:00" "time": "2020-01-22T09:48:42+00:00"
}, },
{ {
"name": "monolog/monolog", "name": "monolog/monolog",

View File

@ -1,19 +1,19 @@
@component('mail::message',['site_name'=>$site_name,'logo'=>$logo]) @component('mail::message',['site'=>$site,'heading'=>'Password Reset'])
# Password Reset Hi {{ isset($user) ? $user->name.',' : '' }}
You are receiving this email because we received a password reset request for your account. You are receiving this email because we received a password reset request for your account.
If you did not request a password reset, no further action is required. If you did not request a password reset, no further action is required.
To reset your password, please follow this link, or click on the URL below: To reset your password, please follow this link, or click on the URL below:
@component('mail::button', ['url' => $reset_link]) @component('mail::panel',['url'=>$reset_link])
Reset Password Reset Password
@endcomponent @endcomponent
@component('mail::panel') @component('mail::subcopy')
Reset password: {{ $reset_link }} Reset password: {{ $reset_link }}
@endcomponent @endcomponent
Thanks,<br> Thanks,<br>
{{ $site_name }} {{ config('mail.from.name') }}
@endcomponent @endcomponent

View File

@ -1,6 +1,6 @@
<div class="header"> <div class="header">
<div class="fixedw"> <div class="fixedw">
<img src="{{ $logo }}"><br> <img src="{{ url($site->email_logo) }}"><br>
<div class="subject">{{ $slot }}</div> <div class="subject">{{ $slot }}</div>
</div> </div>
</div> </div>

View File

@ -1,7 +1,7 @@
@component('mail::layout') @component('mail::layout')
{{-- Header --}} {{-- Header --}}
@slot('header') @slot('header')
@component('mail::header', ['url' => config('app.url'),'logo'=>url($site->email_logo)]) @component('mail::header',['site'=>$site])
{{ $heading }} {{ $heading }}
@endcomponent @endcomponent
@endslot @endslot

View File

@ -1,5 +1,9 @@
<div style="margin: auto; text-align: center; padding-bottom: 20px;"> <div style="margin: auto; text-align: center; padding-bottom: 20px;">
<div class="panel"> <div class="panel">
@isset($url)
<a href="{{ $url }}">{{ $slot }}</a>
@else
{{ $slot }} {{ $slot }}
@endisset
</div> </div>
</div> </div>

View File

@ -41,8 +41,9 @@ body{
border-radius: 10px; border-radius: 10px;
padding: 10px; padding: 10px;
font-weight: 300; font-weight: 300;
margin-top: 20px; margin-top: 10px;
font-size: 0.8em; font-size: 0.8em;
margin-bottom: 10px;
} }
.main-body{ .main-body{
background: #ffffff; background: #ffffff;
@ -74,13 +75,16 @@ body{
font-weight: 300; font-weight: 300;
font-style: normal; font-style: normal;
} }
/* -- TO VALIDATE -- */ .panel a{
a{
text-decoration: underline; text-decoration: underline;
color: #1cbbb4 color: #f4f4f4;
}
.panel a:hover{
text-decoration: none;
color: #ffffff;
} }
a:hover{text-decoration: none;}
/* -- TO VALIDATE -- */
h1{ h1{
font-weight: 300; font-weight: 300;
color: #121212; color: #121212;