设计数据表users的列为(uid, username, email, phone, password) 其中username、email、 phone都应该是unique。
登录时 select 1 from users where username = ' ' or email = ' ' or phone = ' ' and password = ' ';
这样做的缺点是,A的用户名可以设置成是B的电话号码或者邮箱。
可以使用正则表达式来区分出邮箱和电话号码。如果是这两种格式则不允许注册为用户名?
也可以用正则表达式来区分出是邮箱还是电话号码,然后再查数据库。
请求第三方登陆通常会返回一个openid。
设计数据表third为(uid, openid, accessToken, type) ,分别对应users表的uid, 第三方登陆的openid,第三方登陆的accessToken, 第三方登陆的类型(如微博=1、qq=2)。
登录流程: