mirror of
https://github.com/filecoin-project/slate.git
synced 2024-12-26 18:44:56 +03:00
fix(auth): legacy signin password bug
This commit is contained in:
parent
7ec07655dc
commit
5b1380884f
@ -87,5 +87,5 @@ export default async (req, res) => {
|
||||
|
||||
const token = JWT.sign({ id: user.id, username: user.username }, Environment.JWT_SECRET);
|
||||
|
||||
res.status(200).send({ decorator: "SERVER_SIGN_IN", success: true, token });
|
||||
return res.status(200).send({ decorator: "SERVER_SIGN_IN", success: true, token });
|
||||
};
|
||||
|
@ -61,21 +61,18 @@ export const useSignin = ({ onAuthenticate }) => {
|
||||
if (Events.hasError(response)) return;
|
||||
|
||||
// NOTE(amine): handling client hash if the user is v2
|
||||
let hashedPassword;
|
||||
if (response?.data?.version === 1) {
|
||||
hashedPassword = password;
|
||||
} else {
|
||||
hashedPassword = await Utilities.encryptPasswordClient(password);
|
||||
}
|
||||
let hashedPassword = await Utilities.encryptPasswordClient(password);
|
||||
|
||||
credentialsRef.current = { username, password: hashedPassword };
|
||||
|
||||
//NOTE(amine): the onAuthenticate function will return early
|
||||
// if there is shouldMigrate in the response payload
|
||||
const passwordSentToServer = response?.data?.version === 1 ? password : hashedPassword;
|
||||
const authResponse = await onAuthenticate({
|
||||
username: username.toLowerCase(),
|
||||
password: hashedPassword,
|
||||
password: passwordSentToServer,
|
||||
});
|
||||
|
||||
credentialsRef.current = { username, password: hashedPassword };
|
||||
if (authResponse.shouldMigrate) return authResponse;
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user