ADD sync user info api
This commit is contained in:
parent
02d26df172
commit
50fb8d3983
|
@ -4,7 +4,7 @@ class UsersController < ApplicationController
|
||||||
|
|
||||||
before_action :load_user, only: [:show, :homepage_info, :sync_token, :sync_gitea_pwd, :projects, :watch_users, :fan_users]
|
before_action :load_user, only: [:show, :homepage_info, :sync_token, :sync_gitea_pwd, :projects, :watch_users, :fan_users]
|
||||||
before_action :check_user_exist, only: [:show, :homepage_info,:projects, :watch_users, :fan_users]
|
before_action :check_user_exist, only: [:show, :homepage_info,:projects, :watch_users, :fan_users]
|
||||||
before_action :require_login, only: %i[me list]
|
before_action :require_login, only: %i[me list sync_user_info]
|
||||||
before_action :connect_to_ci_db, only: [:get_user_info]
|
before_action :connect_to_ci_db, only: [:get_user_info]
|
||||||
skip_before_action :check_sign, only: [:attachment_show]
|
skip_before_action :check_sign, only: [:attachment_show]
|
||||||
|
|
||||||
|
@ -233,6 +233,26 @@ class UsersController < ApplicationController
|
||||||
render_ok
|
render_ok
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def sync_user_info
|
||||||
|
user = User.find_by_mail params[:email]
|
||||||
|
return render_forbidden unless user === current_user
|
||||||
|
|
||||||
|
sync_params = {
|
||||||
|
email: params[:email],
|
||||||
|
password: params[:password]
|
||||||
|
}
|
||||||
|
|
||||||
|
Users::UpdateInfoForm.new(sync_params).validate!
|
||||||
|
|
||||||
|
interactor = Gitea::User::UpdateInteractor.call(user.login, sync_params)
|
||||||
|
if interactor.success?
|
||||||
|
user.update!(password: params[:password], mail: params[:email], status: User::STATUS_EDIT_INFO)
|
||||||
|
render_ok
|
||||||
|
else
|
||||||
|
render_error(interactor.error)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
def load_user
|
def load_user
|
||||||
@user = User.find_by_login(params[:id]) || User.find_by(id: params[:id])
|
@user = User.find_by_login(params[:id]) || User.find_by(id: params[:id])
|
||||||
|
|
|
@ -218,6 +218,7 @@ Rails.application.routes.draw do
|
||||||
post :sync_salt
|
post :sync_salt
|
||||||
get :trustie_projects
|
get :trustie_projects
|
||||||
get :trustie_related_projects
|
get :trustie_related_projects
|
||||||
|
post :sync_user_info
|
||||||
|
|
||||||
scope '/ci', module: :ci do
|
scope '/ci', module: :ci do
|
||||||
scope do
|
scope do
|
||||||
|
|
Loading…
Reference in New Issue