Class: Remotty::Users::RegistrationsController
- Inherits:
-
Devise::RegistrationsController
- Object
- Devise::RegistrationsController
- Remotty::Users::RegistrationsController
- Includes:
- BaseController
- Defined in:
- app/controllers/remotty/users/registrations_controller.rb
Instance Method Summary collapse
-
#avatar ⇒ Object
POST /resource/avatar 회원 프로필 이미지 수정.
-
#create ⇒ Object
POST /resource 회원가입.
-
#destroy {|resource| ... } ⇒ Object
DELETE /resource 회원탈퇴.
-
#remove_avatar ⇒ Object
DELETE /resource/avatar 회원 프로필 이미지 삭제.
-
#update ⇒ Object
PUT /resource 회원정보 수정 (password 제외한 일반 정보).
Instance Method Details
#avatar ⇒ Object
POST /resource/avatar 회원 프로필 이미지 수정
96 97 98 99 100 101 102 103 104 105 |
# File 'app/controllers/remotty/users/registrations_controller.rb', line 96 def avatar resource.avatar = params[:file] if resource.save render json: resource else render_error 'VALIDATION_ERROR', resource.errors..first end end |
#create ⇒ Object
POST /resource 회원가입
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'app/controllers/remotty/users/registrations_controller.rb', line 8 def create build_resource(sign_up_params) resource.use_password = true # oauth정보가 있으면 validation 체크 if params[:oauth] unless valid_credential?(oauth_params) render_error 'UNAUTHORIZED', 'Oauth credentials information is invalid', :unauthorized and return end end if resource.save yield resource if block_given? resource.add_oauth_info(oauth_params) if params[:oauth] if resource.active_for_authentication? sign_up(resource_name, resource) token = resource.generate_auth_token!(auth_source) render json: resource.with_token(token) else expire_data_after_sign_in! render_error 'UNAUTHORIZED', ("signed_up_but_#{resource.}"), :unauthorized end else clean_up_passwords resource render_error 'VALIDATION_ERROR', resource.errors..first end end |
#destroy {|resource| ... } ⇒ Object
DELETE /resource 회원탈퇴
122 123 124 125 126 127 128 |
# File 'app/controllers/remotty/users/registrations_controller.rb', line 122 def destroy resource.destroy Devise.sign_out_all_scopes ? sign_out : sign_out(resource_name) :notice, :destroyed if is_flashing_format? yield resource if block_given? render nothing: true, status: :no_content end |
#remove_avatar ⇒ Object
DELETE /resource/avatar 회원 프로필 이미지 삭제
109 110 111 112 113 114 115 116 117 118 |
# File 'app/controllers/remotty/users/registrations_controller.rb', line 109 def remove_avatar resource.avatar = nil if resource.save render json: resource else render_error 'VALIDATION_ERROR', resource.errors..first end end |
#update ⇒ Object
PUT /resource 회원정보 수정 (password 제외한 일반 정보)
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 |
# File 'app/controllers/remotty/users/registrations_controller.rb', line 47 def update self.resource = resource_class.to_adapter.get!(send(:"current_#{resource_name}").to_key) prev_unconfirmed_email = resource.unconfirmed_email if resource.respond_to?(:unconfirmed_email) if account_update_params[:password].blank? # password 수정이 아니면 account_update_params.delete("password") account_update_params.delete("password_confirmation") if resource.update_without_password(account_update_params) yield resource if block_given? = update_needs_confirmation?(resource, prev_unconfirmed_email) ? :update_needs_confirmation : :updated sign_in resource_name, resource, :bypass => true, :store => false if == :updated render json: resource else render_error 'UNAUTHORIZED', (), :unauthorized end else clean_up_passwords resource render_error 'VALIDATION_ERROR', resource.errors..first end else # password 수정이면 if resource.use_password resource.update_with_password(account_update_params) else resource.use_password = true resource.update_attributes(account_update_params) clean_up_passwords resource end if resource.errors.blank? render json: resource else render_error 'VALIDATION_ERROR', resource.errors..first end end end |