Class: Platform::Application

Inherits:
Object
  • Object
show all
Includes:
Doorkeeper::Orm::ActiveRecord::Mixins::Application
Defined in:
app/models/platform/application.rb

Instance Method Summary collapse

Instance Method Details

#create_access_tokenObject



41
42
43
# File 'app/models/platform/application.rb', line 41

def create_access_token
  access_tokens.create(resource_owner_id: user.id, description: "Default Access Token", provisioned: true)
end

#create_user_and_membershipObject



34
35
36
37
38
39
# File 'app/models/platform/application.rb', line 34

def create_user_and_membership
  faux_password = SecureRandom.hex
  create_user(email: "noreply+#{SecureRandom.hex}@bullettrain.co", password: faux_password, password_confirmation: faux_password, first_name: label_string)
  create_membership(team: team, user: user, user_email: user.email, platform_agent: true)
  membership.roles << Role.admin
end

#destroy_userObject



49
50
51
52
53
# File 'app/models/platform/application.rb', line 49

def destroy_user
  former_user = membership.user
  membership.nullify_user
  former_user.destroy
end

#label_stringObject

🚅 add delegations above.



30
31
32
# File 'app/models/platform/application.rb', line 30

def label_string
  name
end

#update_user_and_membershipObject



45
46
47
# File 'app/models/platform/application.rb', line 45

def update_user_and_membership
  user.update(first_name: label_string)
end