mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/exchange.git
synced 2026-08-19 04:14:04 +00:00
Email Verification not completed
This commit is contained in:
@@ -69,4 +69,13 @@ class LoginController extends Controller
|
||||
{
|
||||
$this->guard()->logout();
|
||||
}
|
||||
|
||||
public function authenticated(Request $request, $user)
|
||||
{
|
||||
if (!$user->verified) {
|
||||
auth()->logout();
|
||||
return response()->json(['warning','You need to confirm your account first. We have sent you an activation code, please check your email.']);
|
||||
//return back()->with('warning', 'You need to confirm your account. We have sent you an activation code, please check your email.');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,11 +3,13 @@
|
||||
namespace App\Http\Controllers\Auth;
|
||||
|
||||
use App\User;
|
||||
use App\VerifyUser;
|
||||
use App\Role;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use Illuminate\Foundation\Auth\RegistersUsers;
|
||||
use App\Notifications\VerifyEmail;
|
||||
|
||||
class RegisterController extends Controller
|
||||
{
|
||||
@@ -32,7 +34,9 @@ class RegisterController extends Controller
|
||||
*/
|
||||
protected function registered(Request $request, $user)
|
||||
{
|
||||
return $user;
|
||||
$this->guard()->logout();
|
||||
return response()->json(['status'=>'We sent you an activation code. Check your email and click on the link to verify.'],200);
|
||||
return $user;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -66,7 +70,35 @@ class RegisterController extends Controller
|
||||
$user->save();
|
||||
$user->attachRole($role);
|
||||
|
||||
$verifyUser = VerifyUser::create([
|
||||
'user_id' => $user->id,
|
||||
'token' => str_random(40)
|
||||
]);
|
||||
|
||||
//Notification::send($user, new VerifyUser($user));
|
||||
$user->notify(new VerifyEmail($verifyUser));
|
||||
return $user;
|
||||
|
||||
|
||||
}
|
||||
|
||||
public function verifyUser($token)
|
||||
{
|
||||
$verifyUser = VerifyUser::where('token', $token)->first();
|
||||
if(isset($verifyUser) ){
|
||||
$user = $verifyUser->user;
|
||||
if(!$user->verified) {
|
||||
$verifyUser->user->verified = 1;
|
||||
$verifyUser->user->save();
|
||||
return response()->json(['status' => 'Your e-mail is verified. You can now login'], 400);
|
||||
//$status = "Your e-mail is verified. You can now login.";
|
||||
}else{
|
||||
return response()->json(['status' => 'Your e-mail is already verified. Please login.'], 400);
|
||||
//$status = "Your e-mail is already verified. You can now login.";
|
||||
}
|
||||
}else{
|
||||
return response()->json(['warning' => 'Sorry your email cannot be identified.'], 400);
|
||||
//return redirect('/login')->with('warning', "Sorry your email cannot be identified.");
|
||||
}
|
||||
//return response()->json(['status']);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,70 @@
|
||||
<?php
|
||||
|
||||
namespace App\Notifications;
|
||||
use App\User;
|
||||
use App\VerifyUser;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Notifications\Notification;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Notifications\Messages\MailMessage;
|
||||
//use Illuminate\Auth\Notifications\VerifyEmail as Notification;
|
||||
|
||||
class VerifyEmail extends Notification
|
||||
{
|
||||
use Queueable;
|
||||
|
||||
/**
|
||||
* Create a new notification instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
||||
protected $verifyUser;
|
||||
public function __construct(VerifyUser $verifyUser)
|
||||
{
|
||||
$this->verifyUser = $verifyUser;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the notification's delivery channels.
|
||||
*
|
||||
* @param mixed $notifiable
|
||||
* @return array
|
||||
*/
|
||||
public function via($notifiable)
|
||||
{
|
||||
return ['mail'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the mail representation of the notification.
|
||||
*
|
||||
* @param mixed $notifiable
|
||||
* @return \Illuminate\Notifications\Messages\MailMessage
|
||||
*/
|
||||
public function toMail($notifiable)
|
||||
{
|
||||
$verifyUser = $this->verifyUser;
|
||||
$url = url('/user/verify/'.$verifyUser->token);
|
||||
$greeting = sprintf('Greetings %s!', $notifiable->name);
|
||||
return (new MailMessage)
|
||||
->greeting($greeting)
|
||||
->subject("Email Verification")
|
||||
->line('Please verify your email to complete your registration with Exchange.')
|
||||
->action('Verify Your Email', $url)
|
||||
->line('Thank you for using our application!');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the array representation of the notification.
|
||||
*
|
||||
* @param mixed $notifiable
|
||||
* @return array
|
||||
*/
|
||||
public function toArray($notifiable)
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
}
|
||||
}
|
||||
+6
-1
@@ -12,7 +12,7 @@ use Zizaco\Entrust\Traits\EntrustUserTrait;
|
||||
class User extends Authenticatable implements JWTSubject
|
||||
{
|
||||
use Notifiable;
|
||||
use EntrustUserTrait;
|
||||
use EntrustUserTrait;
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
@@ -102,4 +102,9 @@ class User extends Authenticatable implements JWTSubject
|
||||
return $this->hasMany('App\Booking');
|
||||
}
|
||||
|
||||
public function verifyUser()
|
||||
{
|
||||
return $this->hasOne('App\VerifyUser');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace App;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class VerifyUser extends Model
|
||||
{
|
||||
protected $guarded = [];
|
||||
|
||||
public function user()
|
||||
{
|
||||
return $this->belongsTo('App\User', 'user_id');
|
||||
}
|
||||
}
|
||||
@@ -18,6 +18,7 @@ class CreateUsersTable extends Migration
|
||||
$table->string('name');
|
||||
$table->string('email')->unique();
|
||||
$table->string('password');
|
||||
$table->boolean('verified')->default(false);
|
||||
$table->rememberToken();
|
||||
$table->timestamps();
|
||||
});
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class CreateVerifyUsersTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('verify_users', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->integer('user_id');
|
||||
$table->string('token');
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('verify_users');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
<template>
|
||||
<v-alert :value="true" type="success" :form="form" v-if="message===message.status"" dismissible>
|
||||
{{ message.status }}
|
||||
</v-alert>
|
||||
<v-alert :value="true" type="warning" :form="form" v-if="message===message.warning" dismissible>
|
||||
{{ message.warning }}
|
||||
</v-alert>
|
||||
<p>Click <a href="/login">here</a> to login</p>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
middleware: 'guest',
|
||||
|
||||
data: () => ({
|
||||
message: [status: '', warning: ''],
|
||||
form: new Form({
|
||||
token: ''})
|
||||
}),
|
||||
|
||||
created () {
|
||||
this.form.token = this.$route.params.token
|
||||
const { data } = await this.form.post('/api/user/verify/'+this.form.token)
|
||||
},
|
||||
|
||||
/*methods: {
|
||||
|
||||
}
|
||||
}*/
|
||||
}
|
||||
</script>
|
||||
@@ -87,7 +87,7 @@ export default {
|
||||
const { data } = await this.form.post('/api/register')
|
||||
|
||||
// Log in the user.
|
||||
const { data: { token } } = await this.form.post('/api/login')
|
||||
//const { data: { token } } = await this.form.post('/api/login')
|
||||
|
||||
// Save the token.
|
||||
this.$store.dispatch('auth/saveToken', { token })
|
||||
|
||||
@@ -5,6 +5,8 @@ const PasswordEmail = () => import('~/pages/auth/password/email').then(m => m.de
|
||||
const PasswordReset = () => import('~/pages/auth/password/reset').then(m => m.default || m)
|
||||
const NotFound = () => import('~/pages/errors/404').then(m => m.default || m)
|
||||
|
||||
const EmailVerification = () => import('~/pages/auth/EmailVerification').then(m => m.default || m)
|
||||
|
||||
const Home = () => import('~/pages/home').then(m => m.default || m)
|
||||
const Settings = () => import('~/pages/settings/index').then(m => m.default || m)
|
||||
const SettingsProfile = () => import('~/pages/settings/profile').then(m => m.default || m)
|
||||
@@ -20,6 +22,8 @@ export default [
|
||||
{ path: '/password/reset', name: 'password.request', component: PasswordEmail },
|
||||
{ path: '/password/reset/:token', name: 'password.reset', component: PasswordReset },
|
||||
|
||||
{ path: '/user/verify/:token', name: 'email.verification', component: EmailVerification },
|
||||
|
||||
{ path: '/home', name: 'home', component: Home },
|
||||
{ path: '/settings',
|
||||
component: Settings,
|
||||
|
||||
+1
-1
@@ -49,7 +49,7 @@ Route::group(['middleware' => 'guest:api'], function () {
|
||||
Route::post('register', 'Auth\RegisterController@register');
|
||||
Route::post('password/email', 'Auth\ForgotPasswordController@sendResetLinkEmail');
|
||||
Route::post('password/reset', 'Auth\ResetPasswordController@reset');
|
||||
|
||||
Route::get('user/verify/{token}', 'RegisterController@verifyUser');
|
||||
Route::post('oauth/{driver}', 'Auth\OAuthController@redirectToProvider');
|
||||
Route::get('oauth/{driver}/callback', 'Auth\OAuthController@handleProviderCallback')->name('oauth.callback');
|
||||
});
|
||||
|
||||
+1
-1
@@ -12,7 +12,7 @@
|
||||
*/
|
||||
|
||||
Route::get('/', function () {
|
||||
return view('welcome');
|
||||
return view('index');
|
||||
});
|
||||
|
||||
/*Route for the booking */
|
||||
|
||||
+2
-1
@@ -34,6 +34,7 @@ return array(
|
||||
'App\\Http\\Middleware\\TrustProxies' => $baseDir . '/app/Http/Middleware/TrustProxies.php',
|
||||
'App\\Http\\Middleware\\VerifyCsrfToken' => $baseDir . '/app/Http/Middleware/VerifyCsrfToken.php',
|
||||
'App\\Notifications\\ResetPassword' => $baseDir . '/app/Notifications/ResetPassword.php',
|
||||
'App\\Notifications\\VerifyEmail' => $baseDir . '/app/Notifications/VerifyEmail.php',
|
||||
'App\\OAuthProvider' => $baseDir . '/app/OAuthProvider.php',
|
||||
'App\\Permission' => $baseDir . '/app/Permission.php',
|
||||
'App\\Providers\\AppServiceProvider' => $baseDir . '/app/Providers/AppServiceProvider.php',
|
||||
@@ -47,6 +48,7 @@ return array(
|
||||
'App\\SettingCredit' => $baseDir . '/app/SettingCredit.php',
|
||||
'App\\SettingSupplier' => $baseDir . '/app/SettingSupplier.php',
|
||||
'App\\User' => $baseDir . '/app/User.php',
|
||||
'App\\VerifyUser' => $baseDir . '/app/VerifyUser.php',
|
||||
'BookTableSeeder' => $baseDir . '/database/seeds/BookTableSeeder.php',
|
||||
'Carbon\\Carbon' => $vendorDir . '/nesbot/carbon/src/Carbon/Carbon.php',
|
||||
'Carbon\\CarbonInterval' => $vendorDir . '/nesbot/carbon/src/Carbon/CarbonInterval.php',
|
||||
@@ -3726,7 +3728,6 @@ return array(
|
||||
'Tests\\DuskTestCase' => $baseDir . '/tests/DuskTestCase.php',
|
||||
'Tests\\Feature\\LocaleTest' => $baseDir . '/tests/Feature/LocaleTest.php',
|
||||
'Tests\\Feature\\LoginTest' => $baseDir . '/tests/Feature/LoginTest.php',
|
||||
'Tests\\Feature\\OAuthTest' => $baseDir . '/tests/Feature/OAuthTest.php',
|
||||
'Tests\\Feature\\RegisterTest' => $baseDir . '/tests/Feature/RegisterTest.php',
|
||||
'Tests\\Feature\\SettingsTest' => $baseDir . '/tests/Feature/SettingsTest.php',
|
||||
'Tests\\TestCase' => $baseDir . '/tests/TestCase.php',
|
||||
|
||||
Vendored
+12
-11
@@ -4,22 +4,22 @@
|
||||
|
||||
namespace Composer\Autoload;
|
||||
|
||||
class ComposerStaticInitebee75b176540aeb1d879b30f69e9dfc
|
||||
class ComposerStaticInite450fcd5b0627496bb38e1386c9a81ad
|
||||
{
|
||||
public static $files = array (
|
||||
'0e6d7bf4a5811bfa5cf40c5ccd6fae6a' => __DIR__ . '/..' . '/symfony/polyfill-mbstring/bootstrap.php',
|
||||
'25072dd6e2470089de65ae7bf11d3109' => __DIR__ . '/..' . '/symfony/polyfill-php72/bootstrap.php',
|
||||
'667aeda72477189d0494fecd327c3641' => __DIR__ . '/..' . '/symfony/var-dumper/Resources/functions/dump.php',
|
||||
'a0edc8309cc5e1d60e3047b5df6b7052' => __DIR__ . '/..' . '/guzzlehttp/psr7/src/functions_include.php',
|
||||
'2c102faa651ef8ea5874edb585946bce' => __DIR__ . '/..' . '/swiftmailer/swiftmailer/lib/swift_required.php',
|
||||
'a0edc8309cc5e1d60e3047b5df6b7052' => __DIR__ . '/..' . '/guzzlehttp/psr7/src/functions_include.php',
|
||||
'c964ee0ededf28c96ebd9db5099ef910' => __DIR__ . '/..' . '/guzzlehttp/promises/src/functions_include.php',
|
||||
'37a3dc5111fe8f707ab4c132ef1dbc62' => __DIR__ . '/..' . '/guzzlehttp/guzzle/src/functions_include.php',
|
||||
'5255c38a0faeba867671b61dfda6d864' => __DIR__ . '/..' . '/paragonie/random_compat/lib/random.php',
|
||||
'37a3dc5111fe8f707ab4c132ef1dbc62' => __DIR__ . '/..' . '/guzzlehttp/guzzle/src/functions_include.php',
|
||||
'bd9634f2d41831496de0d3dfe4c94881' => __DIR__ . '/..' . '/symfony/polyfill-php56/bootstrap.php',
|
||||
'f0906e6318348a765ffb6eb24e0d0938' => __DIR__ . '/..' . '/laravel/framework/src/Illuminate/Foundation/helpers.php',
|
||||
'58571171fd5812e6e447dce228f52f4d' => __DIR__ . '/..' . '/laravel/framework/src/Illuminate/Support/helpers.php',
|
||||
'6124b4c8570aa390c21fafd04a26c69f' => __DIR__ . '/..' . '/myclabs/deep-copy/src/DeepCopy/deep_copy.php',
|
||||
'801c31d8ed748cfa537fa45402288c95' => __DIR__ . '/..' . '/psy/psysh/src/functions.php',
|
||||
'6124b4c8570aa390c21fafd04a26c69f' => __DIR__ . '/..' . '/myclabs/deep-copy/src/DeepCopy/deep_copy.php',
|
||||
'f18cc91337d49233e5754e93f3ed9ec3' => __DIR__ . '/..' . '/laravelcollective/html/src/helpers.php',
|
||||
);
|
||||
|
||||
@@ -140,8 +140,8 @@ class ComposerStaticInitebee75b176540aeb1d879b30f69e9dfc
|
||||
'phpDocumentor\\Reflection\\' =>
|
||||
array (
|
||||
0 => __DIR__ . '/..' . '/phpdocumentor/reflection-common/src',
|
||||
1 => __DIR__ . '/..' . '/phpdocumentor/reflection-docblock/src',
|
||||
2 => __DIR__ . '/..' . '/phpdocumentor/type-resolver/src',
|
||||
1 => __DIR__ . '/..' . '/phpdocumentor/type-resolver/src',
|
||||
2 => __DIR__ . '/..' . '/phpdocumentor/reflection-docblock/src',
|
||||
),
|
||||
'Zizaco\\Entrust\\' =>
|
||||
array (
|
||||
@@ -433,6 +433,7 @@ class ComposerStaticInitebee75b176540aeb1d879b30f69e9dfc
|
||||
'App\\Http\\Middleware\\TrustProxies' => __DIR__ . '/../..' . '/app/Http/Middleware/TrustProxies.php',
|
||||
'App\\Http\\Middleware\\VerifyCsrfToken' => __DIR__ . '/../..' . '/app/Http/Middleware/VerifyCsrfToken.php',
|
||||
'App\\Notifications\\ResetPassword' => __DIR__ . '/../..' . '/app/Notifications/ResetPassword.php',
|
||||
'App\\Notifications\\VerifyEmail' => __DIR__ . '/../..' . '/app/Notifications/VerifyEmail.php',
|
||||
'App\\OAuthProvider' => __DIR__ . '/../..' . '/app/OAuthProvider.php',
|
||||
'App\\Permission' => __DIR__ . '/../..' . '/app/Permission.php',
|
||||
'App\\Providers\\AppServiceProvider' => __DIR__ . '/../..' . '/app/Providers/AppServiceProvider.php',
|
||||
@@ -446,6 +447,7 @@ class ComposerStaticInitebee75b176540aeb1d879b30f69e9dfc
|
||||
'App\\SettingCredit' => __DIR__ . '/../..' . '/app/SettingCredit.php',
|
||||
'App\\SettingSupplier' => __DIR__ . '/../..' . '/app/SettingSupplier.php',
|
||||
'App\\User' => __DIR__ . '/../..' . '/app/User.php',
|
||||
'App\\VerifyUser' => __DIR__ . '/../..' . '/app/VerifyUser.php',
|
||||
'BookTableSeeder' => __DIR__ . '/../..' . '/database/seeds/BookTableSeeder.php',
|
||||
'Carbon\\Carbon' => __DIR__ . '/..' . '/nesbot/carbon/src/Carbon/Carbon.php',
|
||||
'Carbon\\CarbonInterval' => __DIR__ . '/..' . '/nesbot/carbon/src/Carbon/CarbonInterval.php',
|
||||
@@ -4125,7 +4127,6 @@ class ComposerStaticInitebee75b176540aeb1d879b30f69e9dfc
|
||||
'Tests\\DuskTestCase' => __DIR__ . '/../..' . '/tests/DuskTestCase.php',
|
||||
'Tests\\Feature\\LocaleTest' => __DIR__ . '/../..' . '/tests/Feature/LocaleTest.php',
|
||||
'Tests\\Feature\\LoginTest' => __DIR__ . '/../..' . '/tests/Feature/LoginTest.php',
|
||||
'Tests\\Feature\\OAuthTest' => __DIR__ . '/../..' . '/tests/Feature/OAuthTest.php',
|
||||
'Tests\\Feature\\RegisterTest' => __DIR__ . '/../..' . '/tests/Feature/RegisterTest.php',
|
||||
'Tests\\Feature\\SettingsTest' => __DIR__ . '/../..' . '/tests/Feature/SettingsTest.php',
|
||||
'Tests\\TestCase' => __DIR__ . '/../..' . '/tests/TestCase.php',
|
||||
@@ -4321,10 +4322,10 @@ class ComposerStaticInitebee75b176540aeb1d879b30f69e9dfc
|
||||
public static function getInitializer(ClassLoader $loader)
|
||||
{
|
||||
return \Closure::bind(function () use ($loader) {
|
||||
$loader->prefixLengthsPsr4 = ComposerStaticInitebee75b176540aeb1d879b30f69e9dfc::$prefixLengthsPsr4;
|
||||
$loader->prefixDirsPsr4 = ComposerStaticInitebee75b176540aeb1d879b30f69e9dfc::$prefixDirsPsr4;
|
||||
$loader->prefixesPsr0 = ComposerStaticInitebee75b176540aeb1d879b30f69e9dfc::$prefixesPsr0;
|
||||
$loader->classMap = ComposerStaticInitebee75b176540aeb1d879b30f69e9dfc::$classMap;
|
||||
$loader->prefixLengthsPsr4 = ComposerStaticInite450fcd5b0627496bb38e1386c9a81ad::$prefixLengthsPsr4;
|
||||
$loader->prefixDirsPsr4 = ComposerStaticInite450fcd5b0627496bb38e1386c9a81ad::$prefixDirsPsr4;
|
||||
$loader->prefixesPsr0 = ComposerStaticInite450fcd5b0627496bb38e1386c9a81ad::$prefixesPsr0;
|
||||
$loader->classMap = ComposerStaticInite450fcd5b0627496bb38e1386c9a81ad::$classMap;
|
||||
|
||||
}, null, ClassLoader::class);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user