forked from potsda.mn/mobilizon
Fix lint
This commit is contained in:
parent
ac1dab0fc0
commit
a007160480
|
@ -19,7 +19,7 @@ config :mobilizon, MobilizonWeb.Endpoint,
|
||||||
config :logger,
|
config :logger,
|
||||||
backends: [:console],
|
backends: [:console],
|
||||||
compile_time_purge_level: :debug,
|
compile_time_purge_level: :debug,
|
||||||
level: :debug
|
level: :info
|
||||||
|
|
||||||
# Configure your database
|
# Configure your database
|
||||||
config :mobilizon, Mobilizon.Repo,
|
config :mobilizon, Mobilizon.Repo,
|
||||||
|
|
|
@ -9,15 +9,15 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import NavBar from '@/components/NavBar.vue';
|
import NavBar from '@/components/NavBar.vue';
|
||||||
import { Component, Vue } from 'vue-property-decorator';
|
import { Component, Vue } from 'vue-property-decorator';
|
||||||
import { AUTH_ACCESS_TOKEN, AUTH_USER_ACTOR, AUTH_USER_EMAIL, AUTH_USER_ID } from '@/constants';
|
import { AUTH_ACCESS_TOKEN, AUTH_USER_ACTOR, AUTH_USER_EMAIL, AUTH_USER_ID } from '@/constants';
|
||||||
import { CURRENT_USER_CLIENT, UPDATE_CURRENT_USER_CLIENT } from '@/graphql/user';
|
import { CURRENT_USER_CLIENT, UPDATE_CURRENT_USER_CLIENT } from '@/graphql/user';
|
||||||
import { ICurrentUser } from '@/types/current-user.model';
|
import { ICurrentUser } from '@/types/current-user.model';
|
||||||
import Footer from '@/components/Footer.vue';
|
import Footer from '@/components/Footer.vue';
|
||||||
import Logo from '@/components/Logo.vue';
|
import Logo from '@/components/Logo.vue';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
apollo: {
|
apollo: {
|
||||||
currentUser: {
|
currentUser: {
|
||||||
query: CURRENT_USER_CLIENT,
|
query: CURRENT_USER_CLIENT,
|
||||||
|
@ -34,11 +34,11 @@ export default class App extends Vue {
|
||||||
|
|
||||||
actor = localStorage.getItem(AUTH_USER_ACTOR);
|
actor = localStorage.getItem(AUTH_USER_ACTOR);
|
||||||
|
|
||||||
async mounted () {
|
async mounted() {
|
||||||
await this.initializeCurrentUser();
|
await this.initializeCurrentUser();
|
||||||
}
|
}
|
||||||
|
|
||||||
getUser (): ICurrentUser|false {
|
getUser(): ICurrentUser | false {
|
||||||
return this.currentUser.id ? this.currentUser : false;
|
return this.currentUser.id ? this.currentUser : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -62,42 +62,42 @@ export default class App extends Vue {
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss">
|
<style lang="scss">
|
||||||
@import "variables";
|
@import "variables";
|
||||||
|
|
||||||
/* Bulma imports */
|
/* Bulma imports */
|
||||||
@import "~bulma/sass/base/_all.sass";
|
@import "~bulma/sass/base/_all.sass";
|
||||||
@import "~bulma/sass/components/card.sass";
|
@import "~bulma/sass/components/card.sass";
|
||||||
@import "~bulma/sass/components/media.sass";
|
@import "~bulma/sass/components/media.sass";
|
||||||
@import "~bulma/sass/components/message.sass";
|
@import "~bulma/sass/components/message.sass";
|
||||||
@import "~bulma/sass/components/modal.sass";
|
@import "~bulma/sass/components/modal.sass";
|
||||||
@import "~bulma/sass/components/navbar.sass";
|
@import "~bulma/sass/components/navbar.sass";
|
||||||
@import "~bulma/sass/components/pagination.sass";
|
@import "~bulma/sass/components/pagination.sass";
|
||||||
@import "~bulma/sass/components/dropdown.sass";
|
@import "~bulma/sass/components/dropdown.sass";
|
||||||
@import "~bulma/sass/elements/box.sass";
|
@import "~bulma/sass/elements/box.sass";
|
||||||
@import "~bulma/sass/elements/button.sass";
|
@import "~bulma/sass/elements/button.sass";
|
||||||
@import "~bulma/sass/elements/container.sass";
|
@import "~bulma/sass/elements/container.sass";
|
||||||
@import "~bulma/sass/form/_all";
|
@import "~bulma/sass/form/_all";
|
||||||
@import "~bulma/sass/elements/icon.sass";
|
@import "~bulma/sass/elements/icon.sass";
|
||||||
@import "~bulma/sass/elements/image.sass";
|
@import "~bulma/sass/elements/image.sass";
|
||||||
@import "~bulma/sass/elements/other.sass";
|
@import "~bulma/sass/elements/other.sass";
|
||||||
@import "~bulma/sass/elements/tag.sass";
|
@import "~bulma/sass/elements/tag.sass";
|
||||||
@import "~bulma/sass/elements/title.sass";
|
@import "~bulma/sass/elements/title.sass";
|
||||||
@import "~bulma/sass/elements/notification";
|
@import "~bulma/sass/elements/notification";
|
||||||
@import "~bulma/sass/grid/_all.sass";
|
@import "~bulma/sass/grid/_all.sass";
|
||||||
@import "~bulma/sass/layout/_all.sass";
|
@import "~bulma/sass/layout/_all.sass";
|
||||||
@import "~bulma/sass/utilities/_all";
|
@import "~bulma/sass/utilities/_all";
|
||||||
|
|
||||||
/* Buefy imports */
|
/* Buefy imports */
|
||||||
@import "~buefy/src/scss/utils/_all";
|
@import "~buefy/src/scss/utils/_all";
|
||||||
@import "~buefy/src/scss/components/datepicker";
|
@import "~buefy/src/scss/components/datepicker";
|
||||||
@import "~buefy/src/scss/components/notices";
|
@import "~buefy/src/scss/components/notices";
|
||||||
@import "~buefy/src/scss/components/dropdown";
|
@import "~buefy/src/scss/components/dropdown";
|
||||||
@import "~buefy/src/scss/components/autocomplete";
|
@import "~buefy/src/scss/components/autocomplete";
|
||||||
@import "~buefy/src/scss/components/form";
|
@import "~buefy/src/scss/components/form";
|
||||||
@import "~buefy/src/scss/components/modal";
|
@import "~buefy/src/scss/components/modal";
|
||||||
@import "~buefy/src/scss/components/tag";
|
@import "~buefy/src/scss/components/tag";
|
||||||
@import "~buefy/src/scss/components/taginput";
|
@import "~buefy/src/scss/components/taginput";
|
||||||
@import "~buefy/src/scss/components/upload";
|
@import "~buefy/src/scss/components/upload";
|
||||||
|
|
||||||
.router-enter-active,
|
.router-enter-active,
|
||||||
.router-leave-active {
|
.router-leave-active {
|
||||||
|
|
|
@ -29,4 +29,4 @@ export function buildCurrentUserResolver(cache: ApolloCache<NormalizedCacheObjec
|
||||||
cache.writeData({ data });
|
cache.writeData({ data });
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
};
|
}
|
||||||
|
|
|
@ -45,7 +45,7 @@ export default class AddressAutoComplete extends Vue {
|
||||||
this.data = result.data.searchAddress as IAddress[];
|
this.data = result.data.searchAddress as IAddress[];
|
||||||
}
|
}
|
||||||
|
|
||||||
@Watch("selected")
|
@Watch('selected')
|
||||||
updateSelected() {
|
updateSelected() {
|
||||||
this.$emit('input', this.selected);
|
this.$emit('input', this.selected);
|
||||||
}
|
}
|
||||||
|
|
|
@ -60,18 +60,18 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { Component, Vue, Watch } from 'vue-property-decorator';
|
import { Component, Vue, Watch } from 'vue-property-decorator';
|
||||||
import { CURRENT_USER_CLIENT } from '@/graphql/user';
|
import { CURRENT_USER_CLIENT } from '@/graphql/user';
|
||||||
import { logout } from '@/utils/auth';
|
import { logout } from '@/utils/auth';
|
||||||
import { LOGGED_PERSON } from '@/graphql/actor';
|
import { LOGGED_PERSON } from '@/graphql/actor';
|
||||||
import { IPerson } from '@/types/actor';
|
import { IPerson } from '@/types/actor';
|
||||||
import { CONFIG } from '@/graphql/config';
|
import { CONFIG } from '@/graphql/config';
|
||||||
import { IConfig } from '@/types/config.model';
|
import { IConfig } from '@/types/config.model';
|
||||||
import { ICurrentUser } from '@/types/current-user.model';
|
import { ICurrentUser } from '@/types/current-user.model';
|
||||||
import Logo from '@/components/Logo.vue';
|
import Logo from '@/components/Logo.vue';
|
||||||
import SearchField from '@/components/SearchField.vue';
|
import SearchField from '@/components/SearchField.vue';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
apollo: {
|
apollo: {
|
||||||
currentUser: {
|
currentUser: {
|
||||||
query: CURRENT_USER_CLIENT,
|
query: CURRENT_USER_CLIENT,
|
||||||
|
@ -88,7 +88,7 @@
|
||||||
export default class NavBar extends Vue {
|
export default class NavBar extends Vue {
|
||||||
notifications = [
|
notifications = [
|
||||||
{ header: 'Coucou' },
|
{ header: 'Coucou' },
|
||||||
{ title: "T'as une notification", subtitle: 'Et elle est cool' },
|
{ title: 'T\'as une notification', subtitle: 'Et elle est cool' },
|
||||||
];
|
];
|
||||||
loggedPerson: IPerson | null = null;
|
loggedPerson: IPerson | null = null;
|
||||||
config!: IConfig;
|
config!: IConfig;
|
||||||
|
@ -117,13 +117,13 @@ export default class NavBar extends Vue {
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
@import "../variables.scss";
|
@import "../variables.scss";
|
||||||
|
|
||||||
nav {
|
nav {
|
||||||
border-bottom: solid 1px #0a0a0a;
|
border-bottom: solid 1px #0a0a0a;
|
||||||
|
|
||||||
.navbar-item img {
|
.navbar-item img {
|
||||||
max-height: 2.5em;
|
max-height: 2.5em;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
|
@ -137,9 +137,9 @@ export default class CreateEvent extends Vue {
|
||||||
const obj = {
|
const obj = {
|
||||||
organizerActorId: this.loggedPerson.id,
|
organizerActorId: this.loggedPerson.id,
|
||||||
beginsOn: this.event.beginsOn.toISOString(),
|
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) {
|
if (this.event.physicalAddress) {
|
||||||
delete this.event.physicalAddress['__typename'];
|
delete this.event.physicalAddress['__typename'];
|
||||||
|
|
|
@ -17,14 +17,14 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { VALIDATE_USER } from '@/graphql/user';
|
import { VALIDATE_USER } from '@/graphql/user';
|
||||||
import { Component, Prop, Vue } from 'vue-property-decorator';
|
import { Component, Prop, Vue } from 'vue-property-decorator';
|
||||||
import { AUTH_USER_ID } from '@/constants';
|
import { AUTH_USER_ID } from '@/constants';
|
||||||
import { RouteName } from '@/router';
|
import { RouteName } from '@/router';
|
||||||
import { UserRouteName } from '@/router/user';
|
import { UserRouteName } from '@/router/user';
|
||||||
import { saveTokenData } from '@/utils/auth';
|
import { saveTokenData } from '@/utils/auth';
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
export default class Validate extends Vue {
|
export default class Validate extends Vue {
|
||||||
@Prop({ type: String, required: true }) token!: string;
|
@Prop({ type: String, required: true }) token!: string;
|
||||||
|
|
||||||
|
@ -64,7 +64,7 @@ export default class Validate extends Vue {
|
||||||
saveUserData({ validateUser: login }) {
|
saveUserData({ validateUser: login }) {
|
||||||
localStorage.setItem(AUTH_USER_ID, login.user.id);
|
localStorage.setItem(AUTH_USER_ID, login.user.id);
|
||||||
|
|
||||||
saveTokenData(login)
|
saveTokenData(login);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -231,11 +231,11 @@ defmodule Mobilizon.Users do
|
||||||
"""
|
"""
|
||||||
def authenticate(%{user: user, password: password}) do
|
def authenticate(%{user: user, password: password}) do
|
||||||
# Does password match the one stored in the database?
|
# Does password match the one stored in the database?
|
||||||
case Argon2.verify_pass(password, user.password_hash) do
|
with true <- Argon2.verify_pass(password, user.password_hash),
|
||||||
true ->
|
# Yes, create and return the token
|
||||||
# Yes, create and return the token
|
{:ok, tokens} <- generate_tokens(user) do
|
||||||
with {:ok, tokens} <- generate_tokens(user), do: {:ok, tokens}
|
{:ok, tokens}
|
||||||
|
else
|
||||||
_ ->
|
_ ->
|
||||||
# No, return an error
|
# No, return an error
|
||||||
{:error, :unauthorized}
|
{:error, :unauthorized}
|
||||||
|
@ -252,22 +252,16 @@ defmodule Mobilizon.Users do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def generate_access_token(user) do
|
defp generate_access_token(user) do
|
||||||
with {:ok, access_token, _claims} <-
|
with {:ok, access_token, _claims} <-
|
||||||
MobilizonWeb.Guardian.encode_and_sign(user, %{},
|
MobilizonWeb.Guardian.encode_and_sign(user, %{}, token_type: "access") do
|
||||||
token_type: "access",
|
|
||||||
ttl: {5, :seconds}
|
|
||||||
) do
|
|
||||||
{:ok, access_token}
|
{:ok, access_token}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def generate_refresh_token(user) do
|
def generate_refresh_token(user) do
|
||||||
with {:ok, refresh_token, _claims} <-
|
with {:ok, refresh_token, _claims} <-
|
||||||
MobilizonWeb.Guardian.encode_and_sign(user, %{},
|
MobilizonWeb.Guardian.encode_and_sign(user, %{}, token_type: "refresh") do
|
||||||
token_type: "refresh",
|
|
||||||
ttl: {30, :days}
|
|
||||||
) do
|
|
||||||
{:ok, refresh_token}
|
{:ok, refresh_token}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -89,9 +89,7 @@ defmodule MobilizonWeb.Resolvers.User do
|
||||||
) do
|
) do
|
||||||
with {:ok, user, _claims} <- MobilizonWeb.Guardian.resource_from_token(refresh_token),
|
with {:ok, user, _claims} <- MobilizonWeb.Guardian.resource_from_token(refresh_token),
|
||||||
{:ok, _old, {exchanged_token, _claims}} <-
|
{:ok, _old, {exchanged_token, _claims}} <-
|
||||||
MobilizonWeb.Guardian.exchange(refresh_token, ["access", "refresh"], "access",
|
MobilizonWeb.Guardian.exchange(refresh_token, ["access", "refresh"], "access"),
|
||||||
ttl: {1, :days}
|
|
||||||
),
|
|
||||||
{:ok, refresh_token} <- Users.generate_refresh_token(user) do
|
{:ok, refresh_token} <- Users.generate_refresh_token(user) do
|
||||||
{:ok, %{access_token: exchanged_token, refresh_token: refresh_token}}
|
{:ok, %{access_token: exchanged_token, refresh_token: refresh_token}}
|
||||||
else
|
else
|
||||||
|
|
|
@ -68,7 +68,7 @@ defmodule Mobilizon.UsersTest do
|
||||||
test "authenticate/1 checks the user's password" do
|
test "authenticate/1 checks the user's password" do
|
||||||
{:ok, %User{} = user} = Users.register(%{email: @email, password: @password})
|
{: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} ==
|
assert {:error, :unauthorized} ==
|
||||||
Users.authenticate(%{user: user, password: "bad password"})
|
Users.authenticate(%{user: user, password: "bad password"})
|
||||||
|
|
Loading…
Reference in a new issue