修复:更新邮箱失败
This commit is contained in:
parent
5226196f4e
commit
6f0595616d
|
@ -30,7 +30,7 @@ class Api::V1::Users::UpdateEmailService < ApplicationService
|
||||||
ActiveRecord::Base.transaction do
|
ActiveRecord::Base.transaction do
|
||||||
change_user_email
|
change_user_email
|
||||||
excute_data_to_gitea
|
excute_data_to_gitea
|
||||||
excute_change_email_from_gitea
|
excute_change_email_from_gitea
|
||||||
remove_old_cache_for_user
|
remove_old_cache_for_user
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -61,13 +61,17 @@ class Api::V1::Users::UpdateEmailService < ApplicationService
|
||||||
end
|
end
|
||||||
|
|
||||||
def excute_data_to_gitea
|
def excute_data_to_gitea
|
||||||
Rails.logger.info request_body
|
|
||||||
@gitea_data = $gitea_client.patch_admin_users_by_username(@user.login, {body: request_body.to_json})
|
@gitea_data = $gitea_client.patch_admin_users_by_username(@user.login, {body: request_body.to_json})
|
||||||
end
|
end
|
||||||
|
|
||||||
def excute_change_email_from_gitea
|
def excute_change_email_from_gitea
|
||||||
$gitea_client.delete_user_emails({body: {emails: [@old_mail]}.to_json, query: request_params})
|
emails = $gitea_client.get_user_emails({query: request_params})
|
||||||
$gitea_client.post_user_emails({body: {emails: [@mail]}.to_json, query: request_params})
|
puts "emails=#{emails}"
|
||||||
|
emails.each do |email|
|
||||||
|
email = email.stringify_keys
|
||||||
|
next if email["email"] == @mail
|
||||||
|
$gitea_client.delete_user_emails({body: {emails: [email["email"]]}.to_json, query: request_params})
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def remove_old_cache_for_user
|
def remove_old_cache_for_user
|
||||||
|
|
Loading…
Reference in New Issue