Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
module.exports = (poolData, body, cb) => {
const userPool = new AmazonCognitoIdentity.CognitoUserPool(poolData);
const username = body.username;
const refreshToken = new AmazonCognitoIdentity.CognitoRefreshToken({RefreshToken: body.refreshToken});
const phone_number = body.phone_number;
const userData = {
Username : username,
Pool : userPool
};
let cognitoUser = new AmazonCognitoIdentity.CognitoUser(userData);
// refresh the user session before anything else
return cognitoUser.refreshSession(refreshToken, function(err, userSession) {
if (err) {
return cb(err);
}
cognitoUser.signInUserSession = userSession;
export function newSession({ idToken, refreshToken, accessToken } = {}) {
const token = makeToken();
return new CognitoUserSession({
IdToken: new CognitoIdToken({ IdToken: idToken || token }),
RefreshToken: new CognitoRefreshToken({ RefreshToken: refreshToken || token }),
AccessToken: new CognitoAccessToken({ AccessToken: accessToken || token })
});
}
cognito_user_pool_region = body.cognito_user_pool_region;
var poolData = {
UserPoolId : cognito_user_pool,
ClientId : cognito_client_id
};
var userPool = new AmazonCognitoIdentity.CognitoUserPool(poolData);
var userData = {
Username : email,
Pool : userPool
};
var cognitoUser = new AmazonCognitoIdentity.CognitoUser(userData);
var refresh_token = String(read_id_token(token_filename+"_refreshToken"))
console.log("trying to refresh the token now..");
var refresh_token_object = new AmazonCognitoIdentity.CognitoRefreshToken({ RefreshToken: refresh_token });
cognitoUser.refreshSession(refresh_token_object, (err, session) => {
if(err) {
console.log("error while refreshing the token.."+err);
}
else{
write_id_token(token_filename, String(session.getIdToken().getJwtToken()));
return;
}
});
});
}
module.exports = (poolData, body, cb) => {
const userPool = new AmazonCognitoIdentity.CognitoUserPool(poolData);
const username = body.username;
const oldPassword = body.oldPassword;
const newPassword = body.newPassword;
const refreshToken = new AmazonCognitoIdentity.CognitoRefreshToken({RefreshToken: body.refreshToken});
const userData = {
Username : username,
Pool : userPool
};
let cognitoUser = new AmazonCognitoIdentity.CognitoUser(userData);
return cognitoUser.refreshSession(refreshToken, function(err, userSession) {
if (err) {
return cb(err);
}
cognitoUser.signInUserSession = userSession;
return cognitoUser.changePassword(oldPassword, newPassword, function(err, res) {
if (err) {
async function refreshSession(poolData, body, cb) {
const userPool = new AmazonCognitoIdentity.CognitoUserPool(poolData);
const { username } = body;
const refreshToken = new AmazonCognitoIdentity.CognitoRefreshToken({ RefreshToken: body.refreshToken });
const userData = {
Username: username,
Pool: userPool,
};
const cognitoUser = new AmazonCognitoIdentity.CognitoUser(userData);
cognitoUser.refreshSession(refreshToken, (err, res) => {
if (err) return cb(err);
const data = {
refreshToken: res.getRefreshToken().getToken(),
accessToken: res.getAccessToken().getJwtToken(),
accessTokenExpiresAt: res.getAccessToken().getExpiration(),
idToken: res.getIdToken().getJwtToken(),
module.exports = (poolData, body, cb) => {
const userPool = new AmazonCognitoIdentity.CognitoUserPool(poolData);
const username = body.username;
const enableMfa = body.enableMfa;
const refreshToken = new AmazonCognitoIdentity.CognitoRefreshToken({RefreshToken: body.refreshToken});
const userData = {
Username : username,
Pool : userPool
};
let cognitoUser = new AmazonCognitoIdentity.CognitoUser(userData);
return cognitoUser.refreshSession(refreshToken, function(err, userSession) {
if (err) {
return cb(err);
}
cognitoUser.signInUserSession = userSession;
if (enableMfa === true) {
return cognitoUser.enableMFA(function(err, res) {
module.exports = (poolData, body, cb) => {
const userPool = new AmazonCognitoIdentity.CognitoUserPool(poolData);
const username = body.username;
const refreshToken = new AmazonCognitoIdentity.CognitoRefreshToken({RefreshToken: body.refreshToken});
const userData = {
Username : username,
Pool : userPool
};
let cognitoUser = new AmazonCognitoIdentity.CognitoUser(userData);
return cognitoUser.refreshSession(refreshToken, function(err, userSession) {
if (err) {
return cb(err);
}
cognitoUser.signInUserSession = userSession;
return cognitoUser.getMFAOptions((err, res) => {
if (err) {
export const refreshSession = () => (dispatch, getState) => {
let cognitoUser = getCognitoUser(getState().security.user);
let sessionData = getState().security.session;
let refreshToken = new CognitoRefreshToken({ RefreshToken: sessionData.refreshToken.token });
return new Promise((resolve, reject) => {
cognitoUser.refreshSession(refreshToken, function(err, result) {
if (err) {
dispatch(logoutAction());
reject(err);
}
else {
dispatch(refreshAction(result));
resolve(result);
}
});
});
};
module.exports = (poolData, body, cb) => {
const userPool = new AmazonCognitoIdentity.CognitoUserPool(poolData);
const username = body.username;
const refreshToken = new AmazonCognitoIdentity.CognitoRefreshToken({RefreshToken: body.refreshToken});
const userData = {
Username : username,
Pool : userPool
};
let cognitoUser = new AmazonCognitoIdentity.CognitoUser(userData);
return cognitoUser.refreshSession(refreshToken, function(err, userSession) {
if (err) {
return cb(err);
}
cognitoUser.signInUserSession = userSession;
return cognitoUser.globalSignOut({
onFailure(err) {