|
@@ -362,14 +362,24 @@ export const useMainStore = defineStore("MainStoreId", {
|
|
|
await mainStore.checkApiError(error);
|
|
|
}
|
|
|
},
|
|
|
- async googleLogin(access_token: string) {
|
|
|
+ async googleLogin(username: string) {
|
|
|
try {
|
|
|
- const response = await api.googleLogin(access_token)
|
|
|
- if (response) {
|
|
|
- console.log(response)
|
|
|
+ const response = await api.googleLogin(username);
|
|
|
+ const token: string = response.data.access_token;
|
|
|
+ if (token) {
|
|
|
+ saveLocalToken(token);
|
|
|
+ this.setToken(token);
|
|
|
+ this.setLoggedIn(true);
|
|
|
+ this.setLogInError(false);
|
|
|
+ await this.getUserProfile();
|
|
|
+ await this.routeLoggedIn();
|
|
|
+ this.addNotification({ content: i18n.global.t("loggedIn"), color: "success" });
|
|
|
+ } else {
|
|
|
+ await this.logOut();
|
|
|
}
|
|
|
- } catch (error) {
|
|
|
- await this.checkApiError(error)
|
|
|
+ } catch (err) {
|
|
|
+ this.setLogInError(true);
|
|
|
+ await this.logOut();
|
|
|
}
|
|
|
}
|
|
|
}
|