Class: WithAccounts::MeaningfulController

Inherits:
ApplicationController show all
Defined in:
app/controllers/with_accounts/meaningful_controller.rb

Instance Method Summary collapse

Methods inherited from ApplicationController

#render_around_action_errors, #render_errors, #render_low_camel_cased, #set_json_content_type, #snake_case_params

Methods included from ErrorsHelpers

#error_key, #format_errors

Instance Method Details

#create_access_tokenObject



27
28
29
30
31
32
33
34
# File 'app/controllers/with_accounts/meaningful_controller.rb', line 27

def create_access_token
  data = { access_token: '' }
  performance = Jwts::AccessTokensCreating::Scenario.new(params: params).act_out!
  (render_errors(performance.errors) && return) unless performance.success?

  data.merge!(access_token: performance.stage.new_token)
  render_low_camel_cased(data, :created)
end

#create_login_invitationObject



7
8
9
10
11
12
# File 'app/controllers/with_accounts/meaningful_controller.rb', line 7

def 
  performance = LoginInvitationsCreating::Scenario.new(params: params).act_out!
  (render_errors(performance.errors) && return) unless performance.success?

  render status: :no_content
end

#create_tokensObject



14
15
16
17
18
19
20
21
22
23
24
25
# File 'app/controllers/with_accounts/meaningful_controller.rb', line 14

def create_tokens
  data = { access_token: '', refresh_token: '' }
  performance = Jwts::RefreshTokensCreating::Scenario.new(params: params).act_out!
  (render_errors(performance.errors) && return) unless performance.success?

  data.merge!(refresh_token: performance.stage.new_token)
  performance = Jwts::AccessTokensCreating::Scenario.new(params: { refresh_token: data[:refresh_token] }).act_out!
  (render_errors(performance.errors) && return) unless performance.success?

  data.merge!(access_token: performance.stage.new_token)
  render_low_camel_cased(data, :created)
end

#not_foundObject



3
4
5
# File 'app/controllers/with_accounts/meaningful_controller.rb', line 3

def not_found
  render body: '{"errors": "not found"}', status: 404
end

#set_user_passwordObject



36
37
38
39
40
41
# File 'app/controllers/with_accounts/meaningful_controller.rb', line 36

def set_user_password
  performance = PasswordsCreating::Scenario.new(params: params).act_out!
  (render_errors(performance.errors) && return) unless performance.success?

  render_low_camel_cased({}, :created)
end