Why can users register via the web without even verifying email? - laravel

in laravel user can register and verify email later.
Suppose A registers at www.x.com using B email (so that B cannot register at www.x.com).
when B tries to register at www.x.com using his own email he cannot register because the email is already registered or in DB unique.
So how can I prevent this from happening? I want those who can verify email are people who can register.

Just add Auth::routes(['verify' => true]); in the routes/web.php (see documentation).

Related

Laravel 7 no Verification email sent after a user registers

I followed the instruction of the Laravel documentation 7x for Email Verification.
I didn't do it at the very beginning and before this I made changes to the the users table adding columns like firstnane, familyname, city etc.
Since then I could register correctly without any email verification.
Today I decided to add this functionality but it doesn't work.
The register process is still going on but there is no email sent and the user is directly logged.
I use the
MAIL_MAILER=log
in my .env and other mails are correctly sent and visible in the logs file.
Here is the auth routes
Auth::routes(['verify' => true]);
I have a email_verified_at column in the users table.
Any idea ?
Most likely your User model is not implementing the Illuminate\Contracts\Auth\MustVerifyEmail contract/interface.
use Illuminate\Contracts\Auth\MustVerifyEmail;
...
class User extends Model implements MustVerifyEmail
"Once this interface has been added to your model, newly registered users will automatically be sent an email containing an email verification link." - Laravel 7.x Docs - Email Verification - Model Preparation

How to send email from another address

So I was wondering, how would I send my email from another email address in Laravel. Currently I have this email address and domain. This is an example. Sender = test#domain.com
Now I have many auth()
users. I want to be able for them to send emails as well. So how would I do that? So for an example: Test#anotherdomain.com
My point is, currently the admin guard is able to send an email to the owner of the post who is user(). I have multi auth so admin is one guard and the other is the default.
So the admin is able to send email to test#domain.com
So how can I do it so that test#anotherdomain.com can send an email back to test#domain.com
Is this even possible?
Note: I am using mailgun.
You have two option in this situation:
1) use email clients independently like Phpmailer or Swiftmailer
2) change the config file and email credentials on the fly(make sure your config isn't cached)
Accessing Configuration Values

How to reset passwords in Laravel 5?

I am working on a project using Laravel 5 and I am trying to figure out how to reset passwords. I know the migration for the password resets is already there but I remember there was a ReminderController in Laravel 4 which I could generate but I cannot find the same in Laravel 5.
I am sure that Laravel 5 ships with a password reset mechanism but I cannot exactly figure out where to send the request and the method which handles sending the emails?
I can find the views and the migration but can anyone help me find the controller method and route. If anyone can provide me with a tutorial, I could work with that too.
Laravel also includes an
Auth\PasswordController 
that contains the logic necessary to reset user passwords. We've even provided views to get you started! The views are located in the
resources/views/auth 
directory. You are free to modify these views as you wish to suit your own application's design.
Your user will receive an e-mail with a link that points to the 
getReset method
of the
PasswordController.
This method will render the password reset form and allow users to reset their passwords. After the password is reset, the user will automatically be logged into the application and redirected to /home. You can customize the post-reset redirect location by defining a redirectTo property on the PasswordController:
protected $redirectTo = '/dashboard';
Source

Using email address as username in Tank Auth

I am working on a project with Tank Auth and I would like to use the email addresses of my users as their username to login on the application.
This is the first time I work with a extensive library like this and I'm puzzled.
On the register view I have commented out the input for an email address and in the library of Tank Auth (line 177) I set email to the username as well.
Now when I try to register, I get an error that I can't include underscores or #-signs in the username. Where can I find these restrictions? Because I want to put email addresses here and store them as usernames.
Any advice is more than welcome. If you need more info, just ask :)
I think to can accomplish this with Tank Auth without a big mess.
Tank Auth provides options to activate login by email,username or both.
Simply go to application/config/tank_auth.php and edit the following lines
$config['login_by_username'] = FALSE;
$config['login_by_email'] = TRUE;
Then if you want you can totally remove the username field from 'users' table, register form etc.

Creating users using e-mail address only - ruby on rails

I want to be able to create a user using only their e-mail address.
i.e. I want the admin to be able to enter a bunch of e-mail addresses, which will automatically create a new user and password and then e-mail the information to the address provided.
So I am hoping to figure out how to:
Create users using only e-mail addresses (rest can be randomly generated)
E-mail users their passwords and login details.
Any suggestions on a best way to approach this? I'm using authlogic for authentication.
Cheers!
I'd recommend using devise for this, as it handles generating confirmation emails, as well as the routes for confirming an email. A relevant tutorial for allowing users to sign up with just their email addresses: http://blog.devinterface.com/2011/05/two-step-signup-with-devise/
For having an admin create users, it'll be much the same, just generate random passwords+confirmations, and then call user.send_reset_password_instructions to send the email (which can be customized as in Ruby/Rails: How do you customize the mailer templates of Devise? )
see also: Rails Devise: Set password reset token and redirect user

Resources