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

user auth flow #1

Merged
merged 7 commits into from Jul 11, 2019
Merged

user auth flow #1

merged 7 commits into from Jul 11, 2019

Conversation

SophieDeBenedetto
Copy link
Contributor

@SophieDeBenedetto SophieDeBenedetto commented Jul 10, 2019

This is can probably be refactored a bit but wanted to get the PR up to make sure we're comfortable with this direction:

  • No persistence of users
  • "Authentication" consists of checking for username in params and setting it in session

This PR introduces the following behavior:

As an un-authenticated user
When I visit the root path
I see a welcome page and link to log in
When I click the link to log in, I am taken to /login where I can "log in" with just a username
When I fill out the username field and click "log in"
Then I am redirect to the /cards page and I see the header includes a greeting, "Hi, #{my_username}" and a link to log out

When I do NOT fill out the username field and click "log in"
Then the login page re-renders and I see an error message that the username field cannot be blank

As authenticated user
When I visit the root path
Then I see a welcome page with a link the header to log out
When I click "log out"
I am redirected to the /login path

As an authenticated user
When I visit /cards
Then I see the first card's title and the header includes a link to log out

changeset = User.changeset(%User{}, params["user"])
if changeset.valid? do
user = Ecto.Changeset.apply_changes(changeset)
put_session(conn, :username, user.username)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could refactor this into a function like, login or something more descriptive

@SophieDeBenedetto
Copy link
Contributor Author

I added an extremely DIY logo for now, just to have something fun to look at that isn't the "Phoenix Framework" image.

@SophieDeBenedetto SophieDeBenedetto merged commit ba35aac into master Jul 11, 2019
@michaelstalker michaelstalker deleted the user-session branch September 10, 2019 23:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants