Skip to content

Commit

Permalink
Add sso login (google, github)
Browse files Browse the repository at this point in the history
  • Loading branch information
TimoxGagarin committed Aug 13, 2024
1 parent c718c52 commit 8b8280d
Show file tree
Hide file tree
Showing 5 changed files with 1,774 additions and 1,549 deletions.
5 changes: 5 additions & 0 deletions assets/css/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,8 @@ html {
.cursor-pointer:hover {
cursor: pointer;
}
.sso-auth-button {
color: #4285f4;
border-color: #4285f4;
margin-top: 10px; /* Добавляем отступ между кнопками */
}
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,6 @@
"vue-server-renderer": "<2.7",
"vue-template-compiler": "<2.7",
"vuetify-loader": "1.7.3"
}
},
"packageManager": "[email protected]+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e"
}
39 changes: 39 additions & 0 deletions pages/login/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,33 @@
prepend-icon="lock"
type="password"
/>
<v-layout
column
align-center
justify-center
class="auth-buttons"
mb-6
>
<v-btn
class="sso-auth-button"
color="white"
background="primary"
outlined
@click="ssoAuth('google')"
>
<v-icon left> mdi-google </v-icon>
Sign in with Google
</v-btn>
<v-btn
class="sso-auth-button"
color="white"
outlined
@click="ssoAuth('github')"
>
<v-icon left> mdi-github </v-icon>
Sign in with Github
</v-btn>
</v-layout>
<universal-captcha v-model="captchaCode" />
<UIExtensionSlot name="login_form_extra" />
<div v-if="!$store.state.policies.disable_registration">
Expand Down Expand Up @@ -74,6 +101,12 @@ export default {
askForEmailVerify: false,
}
},
beforeMount() {
const error = this.$route.query.error
if (error) {
this.usernameErrors.push(error)
}
},
methods: {
login() {
this.askForEmailVerify = false
Expand Down Expand Up @@ -120,6 +153,12 @@ export default {
})
}
},
ssoAuth(provider) {
window.open(
this.$axios.defaults.baseURL + "/users/login/" + provider,
"_self"
)
},
},
}
</script>
33 changes: 33 additions & 0 deletions pages/register.vue
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,33 @@
prepend-icon="lock"
type="password"
/>
<v-layout
column
align-center
justify-center
class="auth-buttons"
mb-6
>
<v-btn
class="sso-auth-button"
color="white"
background="primary"
outlined
@click="ssoAuth('google')"
>
<v-icon left> mdi-google </v-icon>
Sign up with Google
</v-btn>
<v-btn
class="sso-auth-button"
color="white"
outlined
@click="ssoAuth('github')"
>
<v-icon left> mdi-github </v-icon>
Sign up with Github
</v-btn>
</v-layout>
<universal-captcha v-model="captchaCode" />
<UIExtensionSlot name="register_form_extra" />
<div>
Expand Down Expand Up @@ -172,6 +199,12 @@ export default {
})
}
},
ssoAuth(provider) {
window.open(
this.$axios.defaults.baseURL + "/users/login/" + provider,
"_self"
)
},
},
}
</script>
Loading

0 comments on commit 8b8280d

Please sign in to comment.