Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to change passwords and bind mailboxes for laravel users

2025-03-04 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

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:

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report