Skip to content

Commit

Permalink
feat(Auth): Facebook auth. Closes #154
Browse files Browse the repository at this point in the history
  • Loading branch information
antoinezanardi committed Mar 25, 2021
1 parent 84c5eff commit 3de2d7c
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 9 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## 1.0.0-beta.12 (2021-??-??)

### 🚀 New features

* [#154](https://github.com/antoinezanardi/werewolves-assistant-web/issues/154) - Facebook auth.

### 📦 Packages

* `vue-facebook-login-component` installed with version `4.0.1`.
Expand Down
8 changes: 8 additions & 0 deletions src/assets/scss/_vue-facebook-login-component.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
.v-facebook-login {
margin: auto;
cursor: pointer !important;

.v-loader {
display: none;
}
}
1 change: 1 addition & 0 deletions src/assets/scss/styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
@import "transitions";
@import "v-tooltip";
@import "vue-backtotop";
@import "vue-facebook-login-component";
@import "vue-flip";
@import "vue-lazyload";
@import "vue-roller";
Expand Down
24 changes: 17 additions & 7 deletions src/components/Home/AccountModal/FacebookLoginButton.vue
Original file line number Diff line number Diff line change
@@ -1,25 +1,34 @@
<template>
<VFacebookLogin ref="facebook" :app-id="appId" :login-options="loginOptions" @login="login" @sdk-init="initSDK"/>
<VFacebookLogin ref="facebook" :app-id="appId" :login-options="loginOptions" @login="login" @sdk-init="initSDK">
<template #login>
<span v-html="$t('FacebookLoginButton.logInWithFacebook')"/>
</template>
<template #working>
<Loading :icon-size="15"/>
</template>
</VFacebookLogin>
</template>

<script>
import { mapActions } from "vuex";
import VFacebookLogin from "vue-facebook-login-component";
import Config from "../../../../config";
import Loading from "@/components/shared/Loading";
export default {
name: "FacebookLoginButton",
components: { VFacebookLogin },
components: { Loading, VFacebookLogin },
data() {
return {
SDK: undefined,
appId: Config.facebook.app.ID,
version: "v10.0",
loginOptions: {
"SDK": undefined,
"appId": Config.facebook.app.ID,
"version": "v10.0",
"loginOptions": {
scope: "email",
// eslint-disable-next-line camelcase
auth_type: "rerequest",
},
"sdk-locale": "fr-FR",
};
},
methods: {
Expand All @@ -32,10 +41,11 @@ export default {
if (data) {
await this.loginWithFacebook(data.authResponse.accessToken);
this.$emit("hide-account-modal");
this.SDK.scope.logout();
}
} catch (err) {
this.$error.display(err);
} finally {
this.SDK.scope.logout();
}
},
},
Expand Down
2 changes: 1 addition & 1 deletion src/components/Home/AccountModal/LoginPanel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
</div>
<div class="row">
<div class="col-12">
<FacebookLoginButton class="mt-2" @hide-account-modal="hideAccountModal"/>
<FacebookLoginButton class="mt-2 text-center" @hide-account-modal="hideAccountModal"/>
</div>
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/error/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const Error = {
Vue.prototype.$error.display = error => {
if (isAPIError(error)) {
const { response } = error;
Vue.prototype.$toasted.error(i18n.t(`Error.${response.data.type}`), { icon: "times" });
Vue.prototype.$toasted.error(i18n.t(`Error.${response.data.type}`), { icon: "times", duration: 5000 });
} else if (Router.currentRoute.name !== "Home" && error.response.status === 401) {
Router.push("/");
Vue.prototype.$toasted.error(i18n.t(`Error.yourSessionHasExpired`), { icon: "times" });
Expand Down
8 changes: 8 additions & 0 deletions src/plugins/vue-i18n/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,9 @@
"loggedInWithFacebook": "Connecté avec Facebook",
"loggedOut": "Déconnecté"
},
"FacebookLoginButton": {
"logInWithFacebook": "Se connecter avec Facebook"
},
"AccountModal": {
"logIn": "Se connecter",
"register": "S'inscrire",
Expand Down Expand Up @@ -1440,6 +1443,11 @@
"EMAIL_EXISTS": "Cet e-mail est déjà utilisé par un autre compte",
"TIE_IN_VOTES": "Il ne peut pas y avoir d'égalité dans les votes",
"TOO_MANY_REQUESTS": "Trop de requêtes d'un coup... Calm down !",
"BAD_FACEBOOK_ACCESS_TOKEN": "Impossible de se connecter avec Facebook",
"NEED_FACEBOOK_EMAIL_PERMISSION": "Veuillez autoriser le partage de votre email pour vous connecter avec Facebook",
"EMAIL_EXISTS_WITH_LOCAL_REGISTRATION": "L'email de ce compte est déjà utilisé par un compte enregistré sur l'Assistant. Veuillez vous connecter directement sur l'Assistant.",
"EMAIL_EXISTS_WITH_FACEBOOK_REGISTRATION": "L'email de ce compte est déjà utilisé par un compte enregistré avec Facebook. Veuillez vous connecter avec Facebook.",
"EMAIL_EXISTS_WITH_GOOGLE_REGISTRATION": "L'email de ce compte est déjà utilisé par un compte enregistré avec Google. Veuillez vous connecter avec Google.",
"yourSessionHasExpired": "Votre session a expirée, veuillez vous reconnecter",
"unknownError": "Erreur inconnue"
},
Expand Down

0 comments on commit 3de2d7c

Please sign in to comment.