mirror of
https://github.com/monkeytypegame/monkeytype.git
synced 2025-02-05 13:27:49 +08:00
added github signin
This commit is contained in:
parent
5a1f56f7ed
commit
18905cc97e
2 changed files with 59 additions and 7 deletions
|
@ -14,7 +14,8 @@ import * as DB from "./db";
|
|||
import * as TestLogic from "./test-logic";
|
||||
import * as UI from "./ui";
|
||||
|
||||
var gmailProvider = new firebase.auth.GoogleAuthProvider();
|
||||
const gmailProvider = new firebase.auth.GoogleAuthProvider();
|
||||
const githubProvider = new firebase.auth.GithubAuthProvider();
|
||||
|
||||
export function signIn() {
|
||||
$(".pageLogin .preloader").removeClass("hidden");
|
||||
|
@ -92,6 +93,40 @@ export async function signInWithGoogle() {
|
|||
}
|
||||
}
|
||||
|
||||
export async function signInWithGitHub() {
|
||||
$(".pageLogin .preloader").removeClass("hidden");
|
||||
|
||||
if ($(".pageLogin .login #rememberMe input").prop("checked")) {
|
||||
//remember me
|
||||
await firebase.auth().setPersistence(firebase.auth.Auth.Persistence.LOCAL);
|
||||
firebase
|
||||
.auth()
|
||||
.signInWithPopup(githubProvider)
|
||||
.then((result) => {
|
||||
console.log(result);
|
||||
})
|
||||
.catch((error) => {
|
||||
Notifications.add(error.message, -1);
|
||||
$(".pageLogin .preloader").addClass("hidden");
|
||||
});
|
||||
} else {
|
||||
//dont remember
|
||||
await firebase
|
||||
.auth()
|
||||
.setPersistence(firebase.auth.Auth.Persistence.SESSION);
|
||||
firebase
|
||||
.auth()
|
||||
.signInWithPopup(githubProvider)
|
||||
.then((result) => {
|
||||
console.log(result);
|
||||
})
|
||||
.catch((error) => {
|
||||
Notifications.add(error.message, -1);
|
||||
$(".pageLogin .preloader").addClass("hidden");
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export function linkWithGoogle() {
|
||||
firebase
|
||||
.auth()
|
||||
|
@ -282,6 +317,11 @@ $(".pageLogin .login .button.signInWithGoogle").click((e) => {
|
|||
signInWithGoogle();
|
||||
});
|
||||
|
||||
$(".pageLogin .login .button.signInWithGitHub").click((e) => {
|
||||
UpdateConfig.setChangedBeforeDb(false);
|
||||
signInWithGitHub();
|
||||
});
|
||||
|
||||
$(".signOut").click((e) => {
|
||||
signOut();
|
||||
});
|
||||
|
@ -325,9 +365,9 @@ firebase.auth().onAuthStateChanged(function (user) {
|
|||
if (VerificationController.data !== null) {
|
||||
VerificationController.verify(user);
|
||||
}
|
||||
}else{
|
||||
} else {
|
||||
UI.setPageTransition(false);
|
||||
if($(".pageLoading").hasClass('active')) UI.changePage('');
|
||||
if ($(".pageLoading").hasClass("active")) UI.changePage("");
|
||||
}
|
||||
let theme = Misc.findGetParameter("customTheme");
|
||||
if (theme !== null) {
|
||||
|
|
|
@ -3827,10 +3827,18 @@
|
|||
<div class="register side">
|
||||
<div class="title">register</div>
|
||||
<form action="" autocomplete="off">
|
||||
<input type="text" placeholder="username" />
|
||||
<input type="text" placeholder="email" />
|
||||
<input type="password" placeholder="password" />
|
||||
<input type="password" placeholder="verify password" />
|
||||
<input type="text" placeholder="username" autocomplete="off" />
|
||||
<input type="text" placeholder="email" autocomplete="off" />
|
||||
<input
|
||||
type="password"
|
||||
placeholder="password"
|
||||
autocomplete="off"
|
||||
/>
|
||||
<input
|
||||
type="password"
|
||||
placeholder="verify password"
|
||||
autocomplete="off"
|
||||
/>
|
||||
<div class="button">
|
||||
<i class="fas fa-user-plus"></i>
|
||||
Sign Up
|
||||
|
@ -3863,6 +3871,10 @@
|
|||
<i class="fab fa-google"></i>
|
||||
Google Sign In
|
||||
</div>
|
||||
<div class="button signInWithGitHub">
|
||||
<i class="fab fa-github"></i>
|
||||
GitHub Sign In
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
|
Loading…
Reference in a new issue