简体   繁体   English

C#中的一次性密码是否在一定时间后到期?

[英]One-Time-Password in C# expires after a certain period?

I'm working on a log in page for a website now in C#.net and have encountered an issue, and was hoping you guys could help me out. 我正在C#.net上正在为一个网站的登录页面进行工作,遇到了一个问题,希望你们能帮助我。

This is the case : The user comes over to the log in screen, then from there they key in their e-mail, we'll reference with the database to check for validity, and if it's valid, a random 8 digit key will be generated and sent to the email. 情况是这样的:用户进入登录屏幕,然后从那里输入电子邮件,我们将参考数据库以检查有效性,如果有效,将随机显示一个8位数字的密钥。生成并发送到电子邮件。 The user should now check his/her email to get the "One-time-password" and then key into one text box to proceed. 用户现在应该检查他/她的电子邮件以获取“一次性密码”,然后键入一个文本框以继续。

The generation and email sending has been done, but I'm not sure how to continue doing this 生成和电子邮件发送已完成,但是我不确定如何继续执行此操作

There's some discussion among my team members, one of them proposed to use a session timeout, and then when the button is clicked, the email will be sent , a session variable will be created and have the one time password stored in it, then we will reference the textbox's text which the user has entered with the session variable and if it's correct, they'll be logged in. 我的团队成员之间进行了一些讨论,其中一个提议使用会话超时,然后单击该按钮时,将发送电子邮件,将创建一个会话变量并在其中存储一次密码,然后我们将引用用户使用会话变量输入的文本框文本,如果正确,则将登录。

Another way I was thinking of is to use Javascript timers, then reference with an invisible label on the web page. 我想到的另一种方法是使用Javascript计时器,然后在网页上使用不可见的标签进行引用。 But I'm not sure if Javascript can allow that to happen.. 但是我不确定Java语言是否可以允许这种情况发生。

What are your best approaches to this situation? 您针对这种情况的最佳方法是什么?

Thanks! 谢谢!

It is time sensitive, just store the code in the database with an expiration datetime. 它是时间敏感的,只需将代码与到期日期时间一起存储在数据库中即可。 Then when the user comes back with their token you can see if it is has not yet expired, if it has then ask them to start the process over. 然后,当用户带着他们的令牌回来时,您可以查看它是否尚未过期,是否已经要求他们重新开始该过程。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM