Comments (7)
Hi @Chalkin thank you for your feedback.
Until the next update you "must" get the user logged in prior to verify the e-mail.
It will be changed and updated soon to allow more flexibility.
Look at this workaround:
#5
About the postRegister
method it's weird! Which version of Laravel do you use?
For Laravel 5.0, 5.1 & 5.2 we overwrite the public function postRegister(Request $request)
in the AuthController.php
file.
Cheers
from laravel-user-verification.
So...
The first thing I would like to share is about the default behaviour of Laravel 5.0 / 5.1 / 5.2:
The postRegister
/ register
method log the user in:
5.0 => $this->auth->login($this->registrar->create($request->all()));
5.1 => Auth::login($this->create($request->all()));
5.2 => Auth::guard($this->getGuard())->login($this->create($request->all()));
That said, I built this package with that in mind without thinking one would like to change this default behaviour. My bad. I think if I want this package to be totally agnostic it should just be able to work without any user logged in.
It means it's probably time for a rewrite and so a version 1.0!
Do you have any comments?
from laravel-user-verification.
thanks a lot for the quick response.
I'm gonna check out the register() thing. I'm using Laravel 5.2
I will keep the user logged in after registration for now. But I can't wait until you update that :)
thanks a lot!
from laravel-user-verification.
@Chalkin I just commited the update in the release v2.0.
The package works now without the need of an authenticated user.
Can you please find the time to test? I updated the documentation too.
Cheers
from laravel-user-verification.
Yep, works now! It's a looooong verification token now.
I probably would have done it another way. But both work.
- Check if the user is authenticated
- If not, i would have gotten the user via the passed verification token
Don't know which way is better.
One thing is still wrong in the documentation.
"Click here to verify your account {{ url('auth/verification/' . $model->verification_token) }}"
needs to be
Click here to verify your account {{ url('auth/verification/' . $user->verification_token) }}
Thanks a lot for changing your package!
from laravel-user-verification.
Just tried to login the user after verification is complete. It does not work with Auth::login($user);
"Argument 1 passed to Illuminate\Auth\SessionGuard::login() must be an instance of Illuminate\Contracts\Auth\Authenticatable, instance of stdClass given"
So i tried to use the Code suggested in #5 from damarev and now it's possible to log the user in. (slightly changed)
`protected function getUserByEmail($email, $table)
{
$userClassName = auth()->getProvider()->getModel();
$userModel = new $userClassName;
$user = $userModel::where('email', $email)->first();
// Already verified
if($user->verified) {
// todo - do something
}
$user->table = $table;
return $user;
}`
from laravel-user-verification.
@Chalkin thank you for the feedback.
The code is still under review and will probably be updated but please let me clarify some details for us.
The wish was to not be tied to to the authentification flow anymore. It is.
- The token is long.
Yes, it's, but is it an issue? I don't think so. I used what Laravel offers us.Crypt
(AES-256-CBC).
I tried to be smart because I knew I will also need to get access to the email address so what I did is simple. I encrypt the email address which becomes the token and then later during the verification process I can just decrypt the token and get the email address.
https://laravel.com/docs/5.2/encryption Auth::login($user)
doesn't work anymore.
Agree. I thought you guys may say one day!
Hey, you designed the package with the User model in mind. What if I want to user another model instead!
So now the retrieved user is an instance of stdClass
.
If you want to authenticate the user you may simply use the Auth::loginUsingId($userId);
.
If you look at the content of the stdClass $user
you will see the following:
{#233 ▼
+"id": "13"
+"name": "jean"
+"email": "[email protected]"
+"password": "xxxx"
+"remember_token": null
+"created_at": "2016-03-23 02:24:06"
+"updated_at": "2016-03-23 02:24:06"
+"verified": "0"
+"verification_token": "eyJpdiI6Ilg3ZHgxZDV1eTNzaUJBZVZCWjUzNGc9PSIsInZhbHVlIjoiSGIycVBjUCtcL1d2bkJPY1lLdk5YZ3gzZklDbTh6TVwvTnFQcHdYWlozdDFjPSIsIm1hYyI6IjBiYWxxxhYjU5ODY3NmQzYzVjZGM3NzFlZDViMjJiOGMxODk2Mjk5ZDQyYWFmOWUwZmExY2FkODMwOTczZjIifQ=="
+"table": "users"
Simply use the id and your are done.
I hope it will help.
I will check how to improve again.
Cheers
from laravel-user-verification.
Related Issues (20)
- composite unique key on email
- Do not work the package for version 7
- Duplicate query while creating new User HOT 2
- missing email_verified_at field in migrations HOT 2
- validateRequest mail validate fail
- not verified handling...
- problem with TokenMismatchException HOT 1
- user password is reset when verified HOT 2
- laravel 6.x HOT 1
- UserVerified event HOT 1
- Laravel Email Verification HOT 2
- Laravel 7.x HOT 2
- Customizable column names
- Not working for multiple guards
- support users in a different db connection
- 9.0 For Laravel support HOT 1
- What is difference with built-in Laravel verification function? HOT 3
- Laravel 8 HOT 2
- Laravel 10 needs new tagged version HOT 1
- Missing required parameter for [Route: email-verification.check] HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from laravel-user-verification.