Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when login with admin email #156

Open
SimonLab opened this issue Oct 19, 2021 · 3 comments
Open

Error when login with admin email #156

SimonLab opened this issue Oct 19, 2021 · 3 comments
Labels
bug Suspected or confirmed bug (defect) in the code

Comments

@SimonLab
Copy link
Member

The seeds file create an admin user from the ADMIN_EMAIL environment variable:

auth/priv/repo/seeds.exs

Lines 20 to 28 in 3a9d687

email = System.get_env("ADMIN_EMAIL")
person =
case Person.get_person_by_email(email) do
nil ->
%Person{}
|> Person.changeset(%{email: email})
# |> put_assoc(:statuses, [%Status{text: "verified"}])
|> Repo.insert!()

When login with this email using email/password the user is retreived from the database and the welcome page is displayed:

def redirect_or_render(conn, person, state) do
# check if valid state (HTTP referer) is defined:
if is_nil(state) or state == "" do
# No State > Display Welcome page on Auth site:
conn
|> AuthPlug.create_jwt_session(session_data(person))
|> Auth.Log.info(%{status_id: 200, app_id: 1})
|> render(:welcome, person: person, apps: App.list_apps(person.id))

However when the user was created with the seed, the value auth_provider is nil which then create an error on the following line:
https://github.com/dwyl/auth/blob/main/lib/auth_web/templates/auth/welcome.html.eex#L7

I think we can add the value email for auth_provider for the admin

@SimonLab SimonLab added the bug Suspected or confirmed bug (defect) in the code label Oct 19, 2021
@nelsonic
Copy link
Member

@SimonLab when are you seeing this error? on your localhost? 💭

@SimonLab
Copy link
Member Author

Yes it's on localhost. It's not a big issue and I think as soon as the admin user authenticate with either Google or Github the auth_provider value is updated (need to double check this)

@nelsonic
Copy link
Member

Yeah, I never login using email and password (as admin) on localhost. So this is an interesting issue. 💭

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Suspected or confirmed bug (defect) in the code
Projects
None yet
Development

No branches or pull requests

2 participants