Make work on Fedora M1 and use faye on http for development

This commit is contained in:
2025-08-29 13:54:43 -05:00
parent 948a787bea
commit 6b02c05a99
8 changed files with 61 additions and 49 deletions
+15 -5
View File
@@ -36,11 +36,9 @@ class User
#view :by_provider, key: [:provider, :uid]
view :by_provider_and_uid, key: [:provider, :uid]
def self.find_for_oauth(auth_data, user)
def self.find_for_oauth(auth_data, controller_current_user)
#user = database.view(self.by_provider(key: [auth_data.provider, auth_data.uid], limit: 1)).first
user = find_by_provider_and_uid(auth_data.provider, auth_data.uid)
user || create(
attributes = {
provider: auth_data.provider,
uid: auth_data.uid,
name: auth_data.info.nickname,
@@ -49,7 +47,19 @@ class User
oauth_token: auth_data.credentials.token,
oauth_expires_at: auth_data.credentials.expires ? Time.at(auth_data.credentials.expires_at) : nil,
auth_data: auth_data
)
}
if user = find_by_email(attributes[:email])
# Update the provider attributes to keep the email unique and valid. This means that
# if two people from other providers, with the same e-mail, can hijack the mozo account.
# probability: around zero
unless user.provider == attributes[:provider] and user.uid == attributes[:uid]
user.update attributes
end
else
user = create attributes
end
user
end
# needed for cmtool