Merge branch 'dev_educoder' of https://git.trustie.net/jasder/forgeplus into dev_educoder

This commit is contained in:
vilet.yy 2021-03-19 11:54:10 +08:00
commit d0532a8f70
4 changed files with 8 additions and 8 deletions

View File

@ -11,7 +11,6 @@ class AccountsController < ApplicationController
Users::SyncGiteaForm.new(sync_gitea_params).validate! Users::SyncGiteaForm.new(sync_gitea_params).validate!
user = User.find_by(login: sync_gitea_params[:login]) user = User.find_by(login: sync_gitea_params[:login])
return render_error("该用户已同步协作平台") if user.gitea_token.present? && user.gitea_uid.present? return render_error("该用户已同步协作平台") if user.gitea_token.present? && user.gitea_uid.present?
user.mail = sync_gitea_params[:email]
interactor = Gitea::RegisterInteractor.call({username: sync_gitea_params[:login], email: sync_gitea_params[:email], password: sync_gitea_params[:password]}) interactor = Gitea::RegisterInteractor.call({username: sync_gitea_params[:login], email: sync_gitea_params[:email], password: sync_gitea_params[:password]})
if interactor.success? if interactor.success?
gitea_user = interactor.result gitea_user = interactor.result
@ -363,7 +362,7 @@ class AccountsController < ApplicationController
{ login: pre + code, email: email, phone: phone } { login: pre + code, email: email, phone: phone }
end end
def sync_gitea_params def sync_gitea_params
params.permit(:login, :email, :password) params.permit(:login, :email, :password)
end end

View File

@ -236,13 +236,12 @@ class UsersController < ApplicationController
# TODO: For Educoder # TODO: For Educoder
def change_password def change_password
user = User.find_by_login params[:login] user = User.find_by_login params[:login]
return render_error("用户 #{rq_params[:login]} 不存在.") unless user === current_user return render_error("用户 #{params[:login]} 不存在.") unless user === current_user
form_params= { form_params= {
login: params[:login], login: params[:login],
email: user&.mail, email: user&.mail,
password: params[:password], password: params[:password],
old_password: params[:old_password],
user: user user: user
} }
Gitea::User::ChangePasswordForm.new(form_params).validate! Gitea::User::ChangePasswordForm.new(form_params).validate!

View File

@ -2,14 +2,13 @@ class Gitea::User::ChangePasswordForm
include ActiveModel::Model include ActiveModel::Model
attr_accessor :user attr_accessor :user
attr_accessor :email, :login, :old_password, :password attr_accessor :email, :login, :password
validates :email, presence: true, format: { with: CustomRegexp::EMAIL } validates :email, presence: true, format: { with: CustomRegexp::EMAIL }
validates :login, presence: true validates :login, presence: true
validates :old_password, presence: true
validates :password, presence: true validates :password, presence: true
validate :check_old_password # validate :check_old_password
def check_old_password def check_old_password
return if user.check_password?(old_password.to_s) return if user.check_password?(old_password.to_s)

View File

@ -52,6 +52,8 @@
# platform :integer default("0") # platform :integer default("0")
# license_id :integer # license_id :integer
# ignore_id :integer # ignore_id :integer
# default_branch :string(255) default("master")
# website :string(255)
# #
# Indexes # Indexes
# #
@ -66,7 +68,8 @@
# index_projects_on_rgt (rgt) # index_projects_on_rgt (rgt)
# index_projects_on_status (status) # index_projects_on_status (status)
# index_projects_on_updated_on (updated_on) # index_projects_on_updated_on (updated_on)
# #
class Project < ApplicationRecord class Project < ApplicationRecord
include Matchable include Matchable