Features of the MVC application request password (i)

Source: Internet
Author: User

After a series of exercises, the member registration "MVC member registration" http://www.cnblogs.com/insus/p/3439599.html is realized,
Login "MVC application Implementation Member login function" http://www.cnblogs.com/insus/p/3466512.html,
And the cancellation of the "MVC Member Logoff function cookie Application" http://www.cnblogs.com/insus/p/3471147.html and other functions.

What's the difference? When a member forgets a password, he or she can request a password or reset his or her password. Now this is what insus.net is capable of. In this demonstration, Insus.net's realization idea is that the member fills in the registration information, such as the account number and the mailbox and so on, then sends a hyperlink to the mailbox, the user opens the link, appears resets the password the webpage. At this point the member can reset the password in the case of a 24-hour validity.


To get started, create a table [dbo] in the database. [Changerequestpassword], when the user requests the password, the store member requests the temporary token information each time:


The token field, which is the unique field that will be used to send to the member. Account and email are used to record the member's request and email. The last field, expire, is a field that has an expired record. The program will link to determine if it is invalid according to the time of this field.

Next, create a message parameter table [dbo]. [Emailparameter]:


A professional site, perhaps not only use a mailbox to send service mail, e-newsletters, membership services, etc., should be sent to the main message listed here.


Finally, create a table that is used to store all subscriptions waiting for the email address to be sent.



Next, create a stored procedure that adds the message parameters:


Below insus.net take Sina mailbox as an example, after logging in, you can see the following information in the options:



To add a sent mailbox parameter, Insus.net uses Sina's mailbox:


In this insus.net recommended users do not try to use the above account and password to log on the above listed mailbox, password is certainly not displayed.

The design of the database has not yet been completed, and several stored procedures are to be written:


The above member requests the password stored procedure, first to determine the member when asks the password the account number and the mailbox is correct.
A new token code is then generated. Of course, this token code, you can also follow your way to produce, uniqueness can be.
#36行代码, is to choose which reference to use in the message parameters, that is, which mailbox to use to send.
#38与 #39 The URL of the line code, is a true correct URL, sure you need to change the URL in your MVC application.
Finally, insert the information into the table of the subscribed mailing list. Wait for the program to process.

Now you can go to the MVC application, open the MemberEntity.cs in the Entities directory, and add a method:



Go to the controller open MemberController.cs add two result:

To create a Requestpassword view, refer to the directory and path:

Code:


Here, this part is finished, members can directly visit this page or we can in the login interface, a link can be directed to this page:


Finally, take a look at the live operation Demo:

The

has reached our original idea in the demo, but the message was still not sent out, just in the Mailinglist list. The next insus.net will implement an MVC application that automatically executes and sends messages.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.