Sha256: 6e6b8de4688fe611ed215e77dac01b9f4842c3a4093f6efeda94e1049c2ee635
Contents?: true
Size: 1.77 KB
Versions: 5
Compression:
Stored size: 1.77 KB
Contents
class ClientsController < ResponseController before_action :set_client, only: [:destroy] before_action :set_params, only: [:create] def show @client = Client.find_by(id: params[:id]) end def create begin @response.add_detail 'nickname' unless NicknameAccessCard.new({value: @params[:nickname]}).valid? @response.add_detail 'email' unless EmailAccessCard.new({value: @params[:email]}).valid? @response.add_detail 'phone' unless PhoneAccessCard.new({value: @params[:phone]}).valid? @response.add_detail 'password' if @params[:password].to_s.length < 8 unless @response.details? client = Client.create ActiveRecord::Base.logger.info("client.user_card #{client.user_card}") client.update({name: @params[:name]}) client.user_card.email_access_cards.create({value: @params[:email]}) client.user_card.nickname_access_cards.create({value: @params[:nickname]}) client.user_card.phone_access_cards.create({value: @params[:phone]}) client.user_card.update({password: @params[:password]}) # require 'authorizer' # authorizer = Authorizer.new # authorizer.authorize! client.user_card, client.user_card.email_access_cards.first client.user_card.authorize! client.user_card.email_access_cards.first current_user @response.set_url profile_path end rescue Exception => error p error @response.error_state error.message @response.set_url root_path end send_response end def destroy @client.destroy redirect_to request.referer end def set_client @client = Client.find(params[:id]) end def set_params @params = params.require(:client).permit(:name, :phone, :email, :nickname, :password) end end
Version data entries
5 entries across 5 versions & 1 rubygems