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

Fix/user object on session #125

Merged
merged 4 commits into from
May 10, 2017
Merged

Fix/user object on session #125

merged 4 commits into from
May 10, 2017

Conversation

pulsedemon
Copy link
Contributor

Add %User{} to session instead of oauth user data.

@@ -9,10 +9,9 @@ defmodule RemoteRetro.RetroController do
conn = put_session conn, "requested_endpoint", conn.request_path
redirect conn, to: "/auth/google"
user ->
user_from_db = Repo.get_by(User, email: user["email"])
query = from p in Participation, where: p.user_id == ^user_from_db.id and p.retro_id == ^params["id"]
query = from p in Participation, where: p.user_id == ^user.id and p.retro_id == ^params["id"]

Choose a reason for hiding this comment

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

Line is too long (max is 80, was 99).

@@ -1,6 +1,6 @@
defmodule RemoteRetro.RetroController do
use RemoteRetro.Web, :controller
alias RemoteRetro.{Retro, Participation, User}
alias RemoteRetro.{Retro, Participation}

Choose a reason for hiding this comment

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

Most of the time you are using the multiple single line alias/require/import/use directives but here you are using the multi-alias/require/import/use syntax

:last_login
]

@derive {Poison.Encoder, only: @required_fields }

Choose a reason for hiding this comment

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

There is no whitespace around parentheses/brackets most of the time, but here there is.

changeset = User.changeset(%User{}, user_params)
Repo.insert!(changeset)
else
changeset = User.changeset(user, user_params)
Repo.update!(changeset)
end

conn = put_session(conn, :current_user, user_info)
user = Map.delete(user, :__meta__)
user = Map.delete(user, :__struct__)

Choose a reason for hiding this comment

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

Variable "user" was declared more than once.

}

user_params = Map.merge(user_params, user_info)

if !user do
user = if !user do

Choose a reason for hiding this comment

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

Avoid negated conditions in if-else blocks.

redirect conn, to: "/auth/google"
user ->
user_from_db = Repo.get_by(User, email: user.email)
query = from p in Participation, where: p.user_id == ^user_from_db.id and p.retro_id == ^params["id"]

Choose a reason for hiding this comment

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

Line is too long (max is 100, was 107).

@@ -13,15 +13,18 @@ defmodule RemoteRetro.AuthController do

user_params = User.build_user_from_oauth(user_info)

if !user do
user = if !user do

Choose a reason for hiding this comment

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

Avoid negated conditions in if-else blocks.

@sourcelevel-bot
Copy link

Ebert has finished reviewing this Pull Request and has found:

  • 3 possible new issues (including those that may have been commented here).
  • 2 fixed issues! 🎉

You can see more details about this review at https://ebertapp.io/github/stride-nyc/remote_retro/pulls/125.

  - because we're relying on a new data structure that gets set in the authentication callback, we have to ensure users with existing sessions don't have their sessions invalidated
@vanderhoop vanderhoop merged commit 75f6eb5 into master May 10, 2017
@vanderhoop vanderhoop deleted the fix/user-object-on-session branch May 10, 2017 00:54
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

3 participants