I'm using cloud functions, and I'm trying to manually override a users password (I also have password email resets set up also).
I can successfully update a user number, enable / disabled status etc however when passing the password variable it seems to fail, with no error message.
The password must be a 'raw, unhashed password. Must be at least six characters long.'
Following the documentation, my cloud function is as follows.
exports.resetUserPassword = functions.https.onCall(async (data, context) => {
if (!context.auth.token.superadmin) return
try {
console.log(data.password)
admin.auth().updateUser(data.uid, {
password: 'testpassword',
})
.then(function(userRecord) {
// See the UserRecord reference doc for the contents of userRecord.
console.log("Successfully updated user", userRecord.toJSON());
})
.catch(function(error) {
console.log("Error updating user:", error);
});
return true
} catch (error) {
console.log(error)
}
});
When I look at the logs for the firebase function, the response seems to indicate the password hasn't been updated (and certainly when I try to log in with the test account the password has been set to something...IDK....). Note that passwordHash and passwordSalt are undefined,
Successfully updated user { uid: 'HMxo5NcObYTN5LPsgSb0ZTCK6213',
email: '[email protected]',
emailVerified: false,
displayName: undefined,
photoURL: undefined,
phoneNumber: undefined,
disabled: false,
metadata:
{ lastSignInTime: 'Tue, 19 May 2020 00:36:16 GMT',
creationTime: 'Tue, 19 May 2020 00:36:16 GMT' },
passwordHash: undefined,
passwordSalt: undefined,
customClaims: { customer: true },
tokensValidAfterTime: 'Tue, 19 May 2020 13:50:02 GMT',
tenantId: undefined,
providerData:
[ { uid: '[email protected]',
displayName: undefined,
email: '[email protected]',
photoURL: undefined,
providerId: 'password',
phoneNumber: undefined } ] }