Get the App
SLTechnology News&Howtos  ›  Development  › 

How to change passwords and bind mailboxes for laravel users

Shulou Source: shulou.com Published: 2022-06-03 17:30:18 09月29日 Update

This article mainly explains "how to change passwords and bind mailboxes for laravel users". Interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn "how laravel users change passwords and bind mailboxes".

Catalogue

First, change the password

1.1 create a modify password controller

1.2 create a change password route

1.3 Test effect

Second, bind mailbox

2.1 bind mailbox controller

2.2 create a corresponding route

2.3 create a class to send mail

2.4 Test effect

Change password 1.1 create a password modification controller

Run the command php artisan make:controller Auth/PasswordController

Write the method of changing password:

/ * change password * / public function updatePassword (Request $request) {$request- > validate (['old_password' = >' required | min:6 | max:16', 'password' = >' required | min:6 | max:16 | confirmed',], ['old_password.required' = >' Old password cannot be empty' 'old_password.min' = >' old password at least 6 characters', 'old_password.max' = >' old password up to 16 characters',]) / / Old password $old_password = $request- > input ('old_password'); / / user instance $user = auth (' api')-> user (); / / verify whether the old password is correct if (! password_verify ($old_password, $user- > password)) {return $this- > response- > errorBadRequest ('incorrect old password') } / / Update user password $user- > password = bcrypt ($request- > input ('password')); $user- > save (); return $this- > response- > noContent ();}

1.2 create modify password routing / / modify password $api- > post ('password/update', [PasswordController::class,' updatePassword'])

1.3 Test effect

Bind mailbox 2.1 bind mailbox controller

Run the command php artisan make:controller Auth/BindController to create a controller that binds the mailbox:

Write the handler that sends the mailbox verification code and updates the mailbox:

Tags: Mailbox password authentication update user controller mail control test command effect route run content character method template queue learning input Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Information Docker Redmi Huawei Xiaomi