mirror of
https://github.com/MrUnknownDE/VRCX.git
synced 2026-05-06 06:46:04 +02:00
Email 2FA OTP
This commit is contained in:
+65
-2
@@ -1139,7 +1139,12 @@ speechSynthesis.getVoices();
|
|||||||
params,
|
params,
|
||||||
origin: true
|
origin: true
|
||||||
};
|
};
|
||||||
if (json.requiresTwoFactorAuth) {
|
if (
|
||||||
|
json.requiresTwoFactorAuth &&
|
||||||
|
json.requiresTwoFactorAuth.includes('emailOtp')
|
||||||
|
) {
|
||||||
|
this.$emit('USER:EMAILOTP', args);
|
||||||
|
} else if (json.requiresTwoFactorAuth) {
|
||||||
this.$emit('USER:2FA', args);
|
this.$emit('USER:2FA', args);
|
||||||
} else {
|
} else {
|
||||||
this.$emit('USER:CURRENT', args);
|
this.$emit('USER:CURRENT', args);
|
||||||
@@ -1186,6 +1191,25 @@ speechSynthesis.getVoices();
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
params: {
|
||||||
|
code: string
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
API.verifyEmailOTP = function (params) {
|
||||||
|
return this.call('auth/twofactorauth/emailotp/verify', {
|
||||||
|
method: 'POST',
|
||||||
|
params
|
||||||
|
}).then((json) => {
|
||||||
|
var args = {
|
||||||
|
json,
|
||||||
|
params
|
||||||
|
};
|
||||||
|
this.$emit('EMAILOTP', args);
|
||||||
|
return args;
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
API.applyUserTrustLevel = function (ref) {
|
API.applyUserTrustLevel = function (ref) {
|
||||||
ref.$isModerator = ref.developerType && ref.developerType !== 'none';
|
ref.$isModerator = ref.developerType && ref.developerType !== 'none';
|
||||||
ref.$isTroll = false;
|
ref.$isTroll = false;
|
||||||
@@ -1355,7 +1379,12 @@ speechSynthesis.getVoices();
|
|||||||
json,
|
json,
|
||||||
origin: true
|
origin: true
|
||||||
};
|
};
|
||||||
if (json.requiresTwoFactorAuth) {
|
if (
|
||||||
|
json.requiresTwoFactorAuth &&
|
||||||
|
json.requiresTwoFactorAuth.includes('emailOtp')
|
||||||
|
) {
|
||||||
|
this.$emit('USER:EMAILOTP', args);
|
||||||
|
} else if (json.requiresTwoFactorAuth) {
|
||||||
this.$emit('USER:2FA', args);
|
this.$emit('USER:2FA', args);
|
||||||
} else {
|
} else {
|
||||||
this.$emit('USER:CURRENT', args);
|
this.$emit('USER:CURRENT', args);
|
||||||
@@ -6043,6 +6072,36 @@ speechSynthesis.getVoices();
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
$app.methods.promptEmailOTP = function () {
|
||||||
|
this.$prompt(
|
||||||
|
'Enter a numeric code that was sent to your email',
|
||||||
|
'Email Two-factor Authentication',
|
||||||
|
{
|
||||||
|
distinguishCancelAndClose: true,
|
||||||
|
cancelButtonText: 'Cancel',
|
||||||
|
confirmButtonText: 'Verify',
|
||||||
|
inputPlaceholder: 'Code',
|
||||||
|
inputPattern: /^[0-9]{6}$/,
|
||||||
|
inputErrorMessage: 'Invalid Code',
|
||||||
|
callback: (action, instance) => {
|
||||||
|
if (action === 'confirm') {
|
||||||
|
API.verifyEmailOTP({
|
||||||
|
code: instance.inputValue
|
||||||
|
})
|
||||||
|
.catch((err) => {
|
||||||
|
this.promptEmailOTP();
|
||||||
|
throw err;
|
||||||
|
})
|
||||||
|
.then((args) => {
|
||||||
|
API.getCurrentUser();
|
||||||
|
return args;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
$app.methods.showExportFriendsListDialog = function () {
|
$app.methods.showExportFriendsListDialog = function () {
|
||||||
var {friends} = API.currentUser;
|
var {friends} = API.currentUser;
|
||||||
if (Array.isArray(friends) === false) {
|
if (Array.isArray(friends) === false) {
|
||||||
@@ -6122,6 +6181,10 @@ speechSynthesis.getVoices();
|
|||||||
$app.promptTOTP();
|
$app.promptTOTP();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
API.$on('USER:EMAILOTP', function () {
|
||||||
|
$app.promptEmailOTP();
|
||||||
|
});
|
||||||
|
|
||||||
API.$on('LOGOUT', function () {
|
API.$on('LOGOUT', function () {
|
||||||
if (this.isLoggedIn) {
|
if (this.isLoggedIn) {
|
||||||
new Noty({
|
new Noty({
|
||||||
|
|||||||
Reference in New Issue
Block a user