Better error handling if no mail got given by OAuth for some reason
This commit is contained in:
parent
02bbdbdcfc
commit
4baadec329
|
@ -80,6 +80,9 @@ passport.use(new JsonStrategy({
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
async function oauthLogin(email, name, discordid = null) {
|
async function oauthLogin(email, name, discordid = null) {
|
||||||
|
if (!email) {
|
||||||
|
throw new Error('You don\'t have a mail set in your account.');
|
||||||
|
}
|
||||||
name = sanitizeName(name);
|
name = sanitizeName(name);
|
||||||
let reguser = await RegUser.findOne({ where: { email } });
|
let reguser = await RegUser.findOne({ where: { email } });
|
||||||
if (!reguser) {
|
if (!reguser) {
|
||||||
|
@ -219,6 +222,12 @@ passport.use(new VkontakteStrategy({
|
||||||
logger.info(profile);
|
logger.info(profile);
|
||||||
const { displayName: name } = profile;
|
const { displayName: name } = profile;
|
||||||
const { email } = params;
|
const { email } = params;
|
||||||
|
if (!email) {
|
||||||
|
done(null, false, {
|
||||||
|
// eslint-disable-next-line max-len
|
||||||
|
message: 'Sorry, you can not use vk login with an account that does not have a verified email set.',
|
||||||
|
});
|
||||||
|
}
|
||||||
const user = await oauthLogin(email, name);
|
const user = await oauthLogin(email, name);
|
||||||
done(null, user);
|
done(null, user);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user