Skip to content

Commit

Permalink
Merge pull request #18 from prafullnavkar-nxg/main
Browse files Browse the repository at this point in the history
fix: resolve issue of authlogin not working
  • Loading branch information
nxglabs authored Oct 26, 2023
2 parents 5bfa83c + e706a3d commit f148661
Showing 1 changed file with 22 additions and 18 deletions.
40 changes: 22 additions & 18 deletions apps/OpenSignServer/cloud/parsefunction/AuthLoginAsMail.js
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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 => {
Expand All @@ -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 {
Expand All @@ -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;

0 comments on commit f148661

Please sign in to comment.