mirror of
https://github.com/OpenSignLabs/OpenSign.git
synced 2026-08-17 21:25:54 +02:00
fix: resolve issue of authlogin not working
This commit is contained in:
@@ -1,7 +1,11 @@
|
||||
import axios from 'axios';
|
||||
async function AuthLoginAsMail(request) {
|
||||
try {
|
||||
//function for login user using user objectId without touching user's password
|
||||
const serverUrl = process.env.SERVER_URL
|
||||
const serverUrl = process.env.SERVER_URL;
|
||||
const APPID = process.env.APP_ID;
|
||||
const masterKEY = process.env.MASTER_KEY;
|
||||
|
||||
let otpN = request.params.otp;
|
||||
let otp = parseInt(otpN);
|
||||
let email = request.params.email;
|
||||
@@ -34,30 +38,31 @@ async function AuthLoginAsMail(request) {
|
||||
url: url,
|
||||
headers: {
|
||||
'Content-Type': 'application/json;charset=utf-8',
|
||||
'X-Parse-Application-Id': process.env.APP_ID,
|
||||
'X-Parse-Master-Key': process.env.MASTER_KEY,
|
||||
'X-Parse-Application-Id': APPID,
|
||||
'X-Parse-Master-Key': masterKEY,
|
||||
},
|
||||
params: {
|
||||
userId: user.id,
|
||||
},
|
||||
}).then(
|
||||
function (httpResponse) {
|
||||
// console.log("httpResponse")
|
||||
// console.log(httpResponse.data)
|
||||
resolve(httpResponse.data);
|
||||
},
|
||||
function (httpResponse) {
|
||||
console.error('User is not found' + httpResponse.status);
|
||||
reject('User is not found!');
|
||||
}
|
||||
);
|
||||
})
|
||||
.then(function (res) {
|
||||
// console.log(res.data)
|
||||
if (res.data) {
|
||||
resolve(res.data);
|
||||
} else {
|
||||
reject('User not found!');
|
||||
}
|
||||
})
|
||||
.catch(err => {
|
||||
reject('user not found!');
|
||||
});
|
||||
// user couldn't find lets sign up!
|
||||
})
|
||||
.catch(() => {
|
||||
let user = new Parse.User();
|
||||
user.set('username', email);
|
||||
user.set('email', email);
|
||||
user.set('password', "12345");
|
||||
user.set('password', '12345');
|
||||
user
|
||||
.save()
|
||||
.then(token => {
|
||||
@@ -70,15 +75,14 @@ async function AuthLoginAsMail(request) {
|
||||
})
|
||||
.catch(e => {
|
||||
console.log('error in auth');
|
||||
reject('user already exists!');
|
||||
console.log(e);
|
||||
return Promise.reject(e);
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
} else {
|
||||
message = `Invalid Otp`;
|
||||
|
||||
return message;
|
||||
}
|
||||
} else {
|
||||
@@ -88,7 +92,7 @@ async function AuthLoginAsMail(request) {
|
||||
} catch (err) {
|
||||
console.log('err in Auth');
|
||||
console.log(err);
|
||||
return Promise.reject('Result not found', err);
|
||||
return 'Result not found', err;
|
||||
}
|
||||
}
|
||||
export default AuthLoginAsMail;
|
||||
|
||||
Reference in New Issue
Block a user