Skip to content

Instantly share code, notes, and snippets.

@zymiboxpay
Last active March 10, 2017 10:44
Show Gist options
  • Save zymiboxpay/7755f5b1bb3a5bc6ba3ee65d3ebff5ee to your computer and use it in GitHub Desktop.
Save zymiboxpay/7755f5b1bb3a5bc6ba3ee65d3ebff5ee to your computer and use it in GitHub Desktop.
password free system

用户的角度

  1. 用户注册/登录
  2. 填写邮箱
  3. 用户收到邮件,点击连接
  4. 若是登录邮件则直接登录,若是注册邮件则确认邮箱且填写用户名

系统的角度

  1. 保存一张注册邮箱数据表,字段有用户ID,邮箱,用户名
  2. 在内存中保存一个 token 哈希表,用在发送给用户的邮件。以 token 值为 key ,内容有:类型(注册/登录),用过一次的以及过期的 token 将删除
  3. 收到注册/登录请求。查询邮箱数据表,若找到,则发送登录邮件,若找不到,则发送注册邮件。邮件内有链接,都是只带一个 token 值。
  4. 收到用户通过点击进来的链接请求,验证 token 存在与否,不存在则显示错误;存在的话,取出类型(注册/登录),注册则显示注册页面,登录则保存用户会话;两者最终都删除 token 。
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment