What are the pros and cons of using an email address as a user id?

前端 未结 15 1591
离开以前
离开以前 2021-01-29 20:15

I\'m creating a web app that requires registration/authentication, and I\'m considering using an email address as the sole user id. Here are what I see as the pros and cons (upd

15条回答
  •  無奈伤痛
    2021-01-29 20:31

    To solve your con item of the email being too long to type in every time. I have implemented the StringScan Ruby library.

    require 'strscan'    
    def signup!(user, &block)    
    self.email = user[:email] unless user[:email].blank?    
    str = StringScanner.new(self.email)    
    str.scan_until(/@/)    
    str.pre_match    
    self.login = str.pre_match
    

    etc..

    Then just change login method to allow either email or login to match password.

    This works just like google or mobileme. A user can choose to just type in their email username (ie. username instead of username@gmail.com.)

提交回复
热议问题