【问题标题】:Google App Engine: Account validation via email confirmationGoogle App Engine:通过电子邮件确认帐户验证
【发布时间】:2014-01-04 04:58:26
【问题描述】:

我的应用不使用 Google 用户服务,而是创建了一个自定义帐户类型来处理用户:

class Account(ndb.Model):
    username = ndb.StringProperty(required = True)
    pw_hash = ndb.StringProperty(required = True)
    email = ndb.StringProperty(required = True)
    created = ndb.DateTimeProperty(auto_now_add = True)

通过电子邮件处理用户帐户验证的最佳方法是什么?我对此很陌生,我还没有接触过电子邮件验证的工作原理。

我猜想,当创建 Account 实体时,会通过邮件模块向注册期间提供的电子邮件发送一封电子邮件。该电子邮件将包含一个“验证”链接。这个链接是什么样子的,它是如何工作的?

任何关于从哪里开始的提示将不胜感激。

【问题讨论】:

    标签: google-app-engine python-2.7 app-engine-ndb webapp2


    【解决方案1】:

    您可以在 Account 中存储一个额外的属性“hashedLink”,它将是随机单词的 md5sum。在电子邮件中将“hashedLink”发送为 /url/activate?link=hashedLink
    每当用户点击链接时,使用 hashedLink 来激活用户的帐户。
    您可以为“忘记密码”功能使用相同的 hashedLink 属性。

    【讨论】:

    • 谢谢,桑迪普。我现在将尝试实现这一点。为了清楚起见,它应该是这样工作的:我假设一个帐户有两种状态:un-authenticatedauthenticated。假设在用户点击/activate?user=6236463746&hashlink=7328ehshsidhw9e8h98 之前,默认帐户是unauthenticated。我设置了一个处理程序get(user, hashlink)。如果它们匹配,处理程序会将帐户状态切换为authenticated。我说的对吗?
    猜你喜欢
    • 1970-01-01
    • 2011-04-20
    • 2011-03-06
    • 2013-08-17
    • 2021-06-16
    • 1970-01-01
    • 2016-10-27
    • 2014-08-17
    • 1970-01-01
    相关资源
    最近更新 更多