生成唯一的用户名(omniauth + devise) [英] generate unique username (omniauth + devise)
问题描述
在我的模型中,我的应用中的用户名是唯一。我不想在我的应用程序中使用重复的用户名。
Facebook中的某些用户在他的个人资料中没有定义的用户名。
如果用户没有在Facebook中定义用户名,我想生成一个唯一的用户名。
例如,生成密码我有这个:
:password => Devise.friendly_token [0,20]
如果Facebook可以为我的应用生成唯一的用户名用户在Facebook中没有用户名?
谢谢
你可以在@符号之前占用一部分电子邮件,并添加像user_id那样的smth,或者只是接收电子邮件。或者你可以从fb响应中组合第一个和最后一个名字。
I have an app with user authentication with devise + omniauth.
In my model that username in my app is unique. I dont want duplicate username in my app.
Some users in facebook has not a defined username in his profile.
I want generate an unique username if the user has not username defined in facebook.
For example for generate password I have this:
:password => Devise.friendly_token[0,20]
How can I generate a unique username for my app if the facebook user has not username in facebook?
Thank you
You can take a part of email before the @ sign and add there smth like user_id, or just take the email itself. Or you can combine somehow the first and last names from the fb response.
这篇关于生成唯一的用户名(omniauth + devise)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!