mirror of
https://github.com/internetee/registry.git
synced 2025-08-02 16:02:03 +02:00
Implement the basic interface for the Authentication endpoint
* Handle errors as 422 * Require parameters through strong_parameters * Use a custom rescue_from
This commit is contained in:
parent
1c6b838b2b
commit
dad57ba528
4 changed files with 35 additions and 11 deletions
|
@ -53,10 +53,14 @@ class RegistrantUser < User
|
|||
end
|
||||
|
||||
def find_or_create_by_api_data(api_data = {})
|
||||
return false unless api_data[:ident]
|
||||
return false unless api_data[:first_name]
|
||||
return false unless api_data[:last_name]
|
||||
|
||||
estonian_ident = "EE-#{api_data[:ident]}"
|
||||
|
||||
user = find_or_create_by(registrant_ident: estonian_ident)
|
||||
user.username = "#{api_data[:first_name]}, #{api_data[:last_name]}"
|
||||
user.username = "#{api_data[:first_name]} #{api_data[:last_name]}"
|
||||
user.save
|
||||
|
||||
user
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue