From a007160480b3ce076d52fac511e06bfe0fbaea3e Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 13 Aug 2019 08:43:37 +0200 Subject: [PATCH] Fix lint --- config/test.exs | 2 +- js/src/App.vue | 88 +++++++++---------- js/src/apollo/user.ts | 2 +- .../components/Event/AddressAutoComplete.vue | 2 +- js/src/components/NavBar.vue | 36 ++++---- js/src/views/Event/Create.vue | 4 +- js/src/views/User/Validate.vue | 16 ++-- lib/mobilizon/users/users.ex | 22 ++--- lib/mobilizon_web/resolvers/user.ex | 4 +- test/mobilizon/users/users_test.exs | 2 +- 10 files changed, 85 insertions(+), 93 deletions(-) diff --git a/config/test.exs b/config/test.exs index e31d9fbfb..21432393b 100644 --- a/config/test.exs +++ b/config/test.exs @@ -19,7 +19,7 @@ config :mobilizon, MobilizonWeb.Endpoint, config :logger, backends: [:console], compile_time_purge_level: :debug, - level: :debug + level: :info # Configure your database config :mobilizon, Mobilizon.Repo, diff --git a/js/src/App.vue b/js/src/App.vue index 2cb8ee27e..2be5576e2 100644 --- a/js/src/App.vue +++ b/js/src/App.vue @@ -9,15 +9,15 @@ diff --git a/js/src/views/Event/Create.vue b/js/src/views/Event/Create.vue index 856432c05..0de44411e 100644 --- a/js/src/views/Event/Create.vue +++ b/js/src/views/Event/Create.vue @@ -137,9 +137,9 @@ export default class CreateEvent extends Vue { const obj = { organizerActorId: this.loggedPerson.id, beginsOn: this.event.beginsOn.toISOString(), - tags: this.event.tags.map((tag: ITag) => tag.title) + tags: this.event.tags.map((tag: ITag) => tag.title), }; - let res = Object.assign({}, this.event, obj); + const res = Object.assign({}, this.event, obj); if (this.event.physicalAddress) { delete this.event.physicalAddress['__typename']; diff --git a/js/src/views/User/Validate.vue b/js/src/views/User/Validate.vue index 02c51d969..76b3237d8 100644 --- a/js/src/views/User/Validate.vue +++ b/js/src/views/User/Validate.vue @@ -17,14 +17,14 @@ diff --git a/lib/mobilizon/users/users.ex b/lib/mobilizon/users/users.ex index 90d10de5d..92697d931 100644 --- a/lib/mobilizon/users/users.ex +++ b/lib/mobilizon/users/users.ex @@ -231,11 +231,11 @@ defmodule Mobilizon.Users do """ def authenticate(%{user: user, password: password}) do # Does password match the one stored in the database? - case Argon2.verify_pass(password, user.password_hash) do - true -> - # Yes, create and return the token - with {:ok, tokens} <- generate_tokens(user), do: {:ok, tokens} - + with true <- Argon2.verify_pass(password, user.password_hash), + # Yes, create and return the token + {:ok, tokens} <- generate_tokens(user) do + {:ok, tokens} + else _ -> # No, return an error {:error, :unauthorized} @@ -252,22 +252,16 @@ defmodule Mobilizon.Users do end end - def generate_access_token(user) do + defp generate_access_token(user) do with {:ok, access_token, _claims} <- - MobilizonWeb.Guardian.encode_and_sign(user, %{}, - token_type: "access", - ttl: {5, :seconds} - ) do + MobilizonWeb.Guardian.encode_and_sign(user, %{}, token_type: "access") do {:ok, access_token} end end def generate_refresh_token(user) do with {:ok, refresh_token, _claims} <- - MobilizonWeb.Guardian.encode_and_sign(user, %{}, - token_type: "refresh", - ttl: {30, :days} - ) do + MobilizonWeb.Guardian.encode_and_sign(user, %{}, token_type: "refresh") do {:ok, refresh_token} end end diff --git a/lib/mobilizon_web/resolvers/user.ex b/lib/mobilizon_web/resolvers/user.ex index ef3f0839f..500036fa3 100644 --- a/lib/mobilizon_web/resolvers/user.ex +++ b/lib/mobilizon_web/resolvers/user.ex @@ -89,9 +89,7 @@ defmodule MobilizonWeb.Resolvers.User do ) do with {:ok, user, _claims} <- MobilizonWeb.Guardian.resource_from_token(refresh_token), {:ok, _old, {exchanged_token, _claims}} <- - MobilizonWeb.Guardian.exchange(refresh_token, ["access", "refresh"], "access", - ttl: {1, :days} - ), + MobilizonWeb.Guardian.exchange(refresh_token, ["access", "refresh"], "access"), {:ok, refresh_token} <- Users.generate_refresh_token(user) do {:ok, %{access_token: exchanged_token, refresh_token: refresh_token}} else diff --git a/test/mobilizon/users/users_test.exs b/test/mobilizon/users/users_test.exs index a7ebceeb9..bb43805ab 100644 --- a/test/mobilizon/users/users_test.exs +++ b/test/mobilizon/users/users_test.exs @@ -68,7 +68,7 @@ defmodule Mobilizon.UsersTest do test "authenticate/1 checks the user's password" do {:ok, %User{} = user} = Users.register(%{email: @email, password: @password}) - assert {:ok, _, _} = Users.authenticate(%{user: user, password: @password}) + assert {:ok, _} = Users.authenticate(%{user: user, password: @password}) assert {:error, :unauthorized} == Users.authenticate(%{user: user, password: "bad password"})