Also support telegram users without username.
This commit is contained in:
parent
cd28e904ac
commit
f317cf1240
1 changed files with 6 additions and 3 deletions
|
@ -223,8 +223,9 @@ returns
|
||||||
auth = Authorization.find_by(uid: message_user[:id], provider: 'telegram')
|
auth = Authorization.find_by(uid: message_user[:id], provider: 'telegram')
|
||||||
|
|
||||||
# create or update user
|
# create or update user
|
||||||
|
login = message_user[:username] || message_user[:id]
|
||||||
user_data = {
|
user_data = {
|
||||||
login: message_user[:username],
|
login: login,
|
||||||
firstname: message_user[:first_name],
|
firstname: message_user[:first_name],
|
||||||
lastname: message_user[:last_name],
|
lastname: message_user[:last_name],
|
||||||
}
|
}
|
||||||
|
@ -232,7 +233,9 @@ returns
|
||||||
user = User.find(auth.user_id)
|
user = User.find(auth.user_id)
|
||||||
user.update_attributes(user_data)
|
user.update_attributes(user_data)
|
||||||
else
|
else
|
||||||
user_data[:note] = "Telegram @#{message_user[:username]}"
|
if message_user[:username]
|
||||||
|
user_data[:note] = "Telegram @#{message_user[:username]}"
|
||||||
|
end
|
||||||
user_data[:active] = true
|
user_data[:active] = true
|
||||||
user_data[:role_ids] = Role.signup_role_ids
|
user_data[:role_ids] = Role.signup_role_ids
|
||||||
user = User.create(user_data)
|
user = User.create(user_data)
|
||||||
|
@ -241,7 +244,7 @@ returns
|
||||||
# create or update authorization
|
# create or update authorization
|
||||||
auth_data = {
|
auth_data = {
|
||||||
uid: message_user[:id],
|
uid: message_user[:id],
|
||||||
username: message_user[:username],
|
username: login,
|
||||||
user_id: user.id,
|
user_id: user.id,
|
||||||
provider: 'telegram'
|
provider: 'telegram'
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue