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

Add Logout Feature + Sessions #159

Merged
merged 59 commits into from
Nov 30, 2021
Merged

Add Logout Feature + Sessions #159

merged 59 commits into from
Nov 30, 2021

Conversation

nelsonic
Copy link
Member

@nelsonic nelsonic commented Nov 7, 2021

@nelsonic nelsonic added the in-progress An issue or pull request that is being worked on by the assigned person label Nov 7, 2021
@nelsonic nelsonic self-assigned this Nov 7, 2021
@nelsonic nelsonic temporarily deployed to dwylauth November 9, 2021 00:29 Inactive
@codecov
Copy link

codecov bot commented Nov 9, 2021

Codecov Report

Merging #159 (cfad7f6) into main (5ccae7e) will not change coverage.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff            @@
##              main      #159   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           22        23    +1     
  Lines          529       554   +25     
=========================================
+ Hits           529       554   +25     
Impacted Files Coverage Δ
lib/auth/log.ex 100.00% <ø> (ø)
lib/auth/session.ex 100.00% <100.00%> (ø)
lib/auth/user_agent.ex 100.00% <100.00%> (ø)
lib/auth_web/controllers/api_controller.ex 100.00% <100.00%> (ø)
lib/auth_web/controllers/auth_controller.ex 100.00% <100.00%> (ø)
lib/auth_web/router.ex 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 5ccae7e...cfad7f6. Read the comment docs.

@nelsonic nelsonic temporarily deployed to dwylauth November 9, 2021 21:54 Inactive
@nelsonic nelsonic mentioned this pull request Nov 10, 2021
2 tasks
@nelsonic nelsonic temporarily deployed to dwylauth November 10, 2021 23:31 Inactive
@nelsonic nelsonic temporarily deployed to dwylauth-pr-159 November 11, 2021 14:52 Inactive
@nelsonic nelsonic temporarily deployed to authdev November 11, 2021 20:32 Inactive
@nelsonic nelsonic temporarily deployed to authdev November 11, 2021 20:37 Inactive
@nelsonic nelsonic temporarily deployed to dwylauth November 11, 2021 20:53 Inactive
end
# defmodule Auth.Mailer do
# use Swoosh.Mailer, otp_app: :auth
# end
Copy link
Member

Choose a reason for hiding this comment

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

Compiling the project returns the following warning and error:
image

I think there are more things to comment or remove to make sure Swoosh is removed.
Looking at dwyl/phoenix-chat-example#66 to see what I've done to remove it

Copy link
Member Author

Choose a reason for hiding this comment

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

Merci Simon. 🙏

Copy link
Member

Choose a reason for hiding this comment

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

It works fine on a fresh git clone. I think it might have been a conflict in my dependencies with another branch.
However swoosh is still defined in mix.lock file. If we want to remove the dependency completely we can run mix deps.clean --unused --unlock

web: MIX_ENV=prod mix ecto.migrate && mix assets.deploy && mix phx.server
Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure if we need to run assets.deploy in Procfile.
The elixir_buildbpack file run this command already:
https://github.com/dwyl/auth/blob/main/elixir_buildpack.config

Copy link
Member Author

@nelsonic nelsonic Nov 29, 2021

Choose a reason for hiding this comment

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

@SimonLab perfect. I was in doubt that it was working. but if you've confirmed it, let's remove it. 👍

@nelsonic nelsonic temporarily deployed to dwylauth November 29, 2021 16:01 Inactive
@nelsonic nelsonic temporarily deployed to dwylauth November 29, 2021 16:14 Inactive
Comment on lines +66 to +67
|> assign(:sid, session_id)
|> Auth.Session.end_session()
Copy link
Member

Choose a reason for hiding this comment

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

Here the sid is added to conn so the end_session function can update the end session value. The sid is then removed from the conn.
Instead of passing conn to the function I think we can pass the session_id directly. We'll need to udpate also the parameter for end_session and update_session_end but I think it makes things a be more easy to read and we'll be able to remove |> assign(:sid, session_id)

Copy link
Member Author

Choose a reason for hiding this comment

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

That seems like a sensible refactor. The only reason I was doing adding the sid to conn was for pipeline. But if instead we make the session_id the second parameter of Auth.Session.end_session then it will be much cleaner. 💭

Copy link
Member

Choose a reason for hiding this comment

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

I think we can even remove completely the conn and just have one argument. I'll check this on a new branch

Co-authored-by: Simon <simon.labondance@gmail.com>
@SimonLab
Copy link
Member

Not sure why a conflict appears with the latest commit:
image

I'll delete the spaces

@SimonLab SimonLab temporarily deployed to dwylauth November 30, 2021 13:03 Inactive
Copy link
Member

@SimonLab SimonLab left a comment

Choose a reason for hiding this comment

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

Sessions looks good, thanks.
I still find the auth_controller a bit long and not as easy to read.
Hopefully the next PRs will make this easier to navigate

@SimonLab SimonLab merged commit 35eca6a into main Nov 30, 2021
@SimonLab SimonLab deleted the logout-endpoint-issue-158 branch November 30, 2021 14:30
@nelsonic
Copy link
Member Author

@SimonLab yeah, the auth_controller is definitely too big and could easily be split/simplified: https://github.com/dwyl/auth_plug/issues/40

@nelsonic nelsonic mentioned this pull request Dec 18, 2021
3 tasks
@nelsonic nelsonic mentioned this pull request Jun 18, 2022
6 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting-review An issue or pull request that needs to be reviewed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants