add: require profile completed

This commit is contained in:
yystopf 2021-08-31 18:00:54 +08:00
parent 5b7f8e8da6
commit c52458a7e3
12 changed files with 15 additions and 0 deletions

View File

@ -246,6 +246,10 @@ class ApplicationController < ActionController::Base
tip_exception(401, "请登录后再操作") unless User.current.logged?
end
def require_profile_completed
tip_exception(411, "请完善资料后再操作") unless User.current.profile_completed
end
# 异常提醒
def tip_exception(status = -1, message)
raise Educoder::TipException.new(status, message)

View File

@ -1,5 +1,6 @@
class ForksController < ApplicationController
before_action :require_login
before_action :require_profile_completed, only: [:create]
before_action :load_project
before_action :authenticate_project!, :authenticate_user!

View File

@ -1,5 +1,6 @@
class IssuesController < ApplicationController
before_action :require_login, except: [:index, :show, :index_chosen]
before_action :require_profile_completed, only: [:create]
before_action :load_project
before_action :set_user
before_action :check_issue_permission

View File

@ -1,5 +1,6 @@
class JournalsController < ApplicationController
before_action :require_login, except: [:index, :get_children_journals]
before_action :require_profile_completed, only: [:create]
before_action :set_issue
before_action :check_issue_permission
before_action :set_journal, only: [:destroy, :edit, :update]

View File

@ -1,5 +1,6 @@
class Organizations::OrganizationsController < Organizations::BaseController
before_action :require_login, except: [:index, :show, :recommend]
before_action :require_profile_completed, only: [:create]
before_action :convert_image!, only: [:create, :update]
before_action :load_organization, only: [:show, :update, :destroy]
before_action :check_user_can_edit_org, only: [:update, :destroy]

View File

@ -1,5 +1,6 @@
class PraiseTreadController < ApplicationController
before_action :require_login, except: %i[index]
before_action :require_profile_completed, only: [:like]
before_action :find_project_with_id
def index

View File

@ -1,4 +1,5 @@
class Projects::ProjectAppliesController < Projects::BaseController
before_action :require_profile_completed, only: [:create]
def create
project = Projects::ApplyJoinService.call(current_user, create_params)
render_ok(project_id: project.id)

View File

@ -5,6 +5,7 @@ class ProjectsController < ApplicationController
include Acceleratorable
before_action :require_login, except: %i[index branches group_type_list simple show fork_users praise_users watch_users recommend about menu_list]
before_action :require_profile_completed, only: [:create, :migrate]
before_action :load_repository, except: %i[index group_type_list migrate create recommend]
before_action :authorizate_user_can_edit_project!, only: %i[update]
before_action :project_public?, only: %i[fork_users praise_users watch_users]

View File

@ -1,5 +1,6 @@
class PullRequestsController < ApplicationController
before_action :require_login, except: [:index, :show, :files, :commits]
before_action :require_profile_completed, only: [:create]
before_action :load_repository
before_action :find_pull_request, except: [:index, :new, :create, :check_can_merge,:get_branches,:create_merge_infos, :files, :commits]
before_action :load_pull_request, only: [:files, :commits]

View File

@ -78,6 +78,7 @@ class UsersController < ApplicationController
return render_forbidden unless User.current.logged? && (current_user&.admin? || current_user.id == @user.id)
Util.write_file(@image, avatar_path(@user)) if user_params[:image].present?
@user.attributes = user_params.except(:image)
@user.profile_completed = true if @user.nickname.present? && @user.gender.present? && @user.mail.present? && @user.custom_department.present?
unless @user.save
render_error(@user.errors.full_messages.join(", "))
end

View File

@ -1,5 +1,6 @@
class VersionsController < ApplicationController
before_action :require_login, except: [:index, :show]
before_action :require_profile_completed, only: [:create]
before_action :load_repository
before_action :check_issue_permission, except: [:show, :index]
before_action :set_version, only: [:edit, :update, :destroy, :show,:update_status]

View File

@ -1,5 +1,6 @@
class WatchersController < ApplicationController
before_action :require_login, except: %i[index]
before_action :require_profile_completed, only: [:follow]
# before_action :find_project_with_id
before_action :get_target