Auth.Person (auth v1.6.0)

Defines Person schema and CRUD functions

Link to this section Summary

Functions

Default attributes validation for Person

decrypt_email/1 accepts a cyphertext and attempts to Base58.decode followed by AES.decrypt it. If decode or decrypt fails, return 0 (zero).

get_person_by_email/1 returns the person based on email address.

transform_github_profile_data_to_person/1 transforms the profile data received from invoking ElixirAuthGithub.github_auth/1 into a person record that can be inserted into the people table.

transform_profile_data_to_person/1 transforms the profile data received from invoking ElixirAuthGoogle.get_user_profile/1 into a person record that can be inserted into the people table.

upsert_person/1 inserts or updates a person record.

Link to this section Functions

Link to this function

changeset(person, attrs)

Default attributes validation for Person

Link to this function

create_github_person(profile)

Link to this function

create_google_person(profile)

Link to this function

create_person(person)

Link to this function

decrypt(ciphertext)

Link to this function

decrypt_email(cyphertext)

decrypt_email/1 accepts a cyphertext and attempts to Base58.decode followed by AES.decrypt it. If decode or decrypt fails, return 0 (zero).

Link to this function

get_list_of_people()

Link to this function

get_person_by_email(email)

get_person_by_email/1 returns the person based on email address.

Link to this function

get_person_by_id(id)

Link to this function

get_status_verified()

Link to this function

login_register_changeset(attrs)

Link to this function

password_new_changeset(attrs)

Link to this function

put_email_status_verified(changeset)

Link to this function

transform_github_profile_data_to_person(profile)

transform_github_profile_data_to_person/1 transforms the profile data received from invoking ElixirAuthGithub.github_auth/1 into a person record that can be inserted into the people table.

Example

iex> transform_profile_data_to_person(%{

avatar_url: "https://avatars3.githubusercontent.com/u/194400?v=4",
email: "alex@gmail.com",
followers: 2846,
login: "alex",
name: "Alex McAwesome",
type: "User",
url: "https://api.github.com/users/alex"

}) %{

"email" => "nelson@gmail.com",
"picture" => "https://avatars3.githubusercontent.com/u/194400?v=4",
"status" => 1,
"givenName" => "Alex McAwesome"

}

Link to this function

transform_google_profile_data_to_person(profile)

transform_profile_data_to_person/1 transforms the profile data received from invoking ElixirAuthGoogle.get_user_profile/1 into a person record that can be inserted into the people table.

Example

iex> transform_profile_data_to_person(%{

"email" => "nelson@gmail.com",
"email_verified" => true,
"family_name" => "Correia",
"given_name" => "Nelson",
"locale" => "en",
"name" => "Nelson Correia",
"picture" => "https://lh3.googleusercontent.com/a-/AAuE7mApnYb260YC1JY7a",
"sub" => "940732358705212133793"

}) %{

"email" => "nelson@gmail.com",
"email_verified" => true,
"family_name" => "Correia",
"given_name" => "Nelson",
"locale" => "en",
"name" => "Nelson Correia",
"picture" => "https://lh3.googleusercontent.com/a-/AAuE7mApnYb260YC1JY7a",
"sub" => "940732358705212133793"
"status" => 1,
"familyName" => "Correia",
"givenName" => "Nelson"

}

Link to this function

upsert_person(person)

upsert_person/1 inserts or updates a person record.

Link to this function

verify_person_by_id(id)