-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathservice_api_user.rb
40 lines (34 loc) · 1.06 KB
/
service_api_user.rb
1
2
3
4
5
6
7
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
# ActiveHash allows you to create ActiveRecord-like objects that are hard
# coded. This saves us from having to make changes to the database to create
# this model.
#
# To obtain an API token for a user, run this in the console:
#
# ServiceAPIUser.tad_user.create_magic_link_token!
class ServiceAPIUser < ActiveHash::Base
include ActiveHash::Associations
include AuthenticatedUsingMagicLinks
self.data = [
{ id: 1, name: 'User for testing, not used in production', authorized_api: 'TestAPI' },
{ id: 2, name: 'DfE TAD', authorized_api: 'DataAPI' },
{ id: 3, name: 'DfE Register', authorized_api: 'RegisterAPI' },
{ id: 4, name: 'DfE Candidate', authorized_api: 'CandidateAPI' },
]
def self.test_data_user
find(1)
end
def self.tad_user
find(2)
end
def self.register_user
find(3)
end
def self.candidate_user
find(4)
end
# Fix a bug in ActiveHash that causes the user_type in a AuthenticationToken to
# be set to `ActiveHash::Base` instead of `ServiceAPIUser`.
def self.polymorphic_name
'ServiceAPIUser'
end
end