1 # frozen_string_literal: true
3 class AccountsController < ApplicationController
9 before_action :authorize_web
10 before_action :set_locale
12 authorize_resource :class => false
14 before_action :check_database_readable
15 before_action :check_database_writable, :only => [:update]
17 allow_thirdparty_images :only => [:show, :update]
18 allow_social_login :only => [:show, :update]
21 if errors = session.delete(:user_errors)
22 errors.each do |attribute, error|
23 current_user.errors.add(attribute, error)
30 user_params = params.expect(:user => [:display_name, :new_email, :pass_crypt, :pass_crypt_confirmation, :auth_provider])
32 if params[:user][:auth_provider].blank? ||
33 params[:user][:auth_provider] == current_user.auth_provider
34 update_user(current_user, user_params)
35 if current_user.errors.empty?
36 redirect_to account_path
41 session[:new_user_settings] = user_params.to_h
42 redirect_to auth_url(params[:user][:auth_provider]), :status => :temporary_redirect
47 if current_user.deletion_allowed?
48 current_user.soft_destroy!
51 session_expires_automatically
53 flash[:notice] = t ".success"