#I have a problem with data and hash arguments
51 messages · Page 1 of 1 (latest)
but the log pw login functie api is not called twice
so i dont think it is login thats called twice
ok
I didn't get why you have two logs of hashed and validateuser same password then
actually, validateUser is called twice, I guess
not sure why
i am confused, and is this why the error happens?
your validateUser seems to be called twice
And we can't tell why
in its second call, you have password === undefined
and that's why bcrypt.compare will raise that error
yeah but check out your logs, you got those console.log called twice
ye but i have this log twice
so i dont know why this happens twice
i know its called twice thats why i am asking help
because the second call is undefined but i never do a second call
isn´t that due to some error on the client side?
Did you double checked if the client is making the right request?
I didn´t see anything wrong with your server code so far
yes i did check
wait i can send part of client code whats happening
onSubmit() {
this.submitted = true;
this.loading = true;
this.mymodel.username = this.loginForm.get('username')?.value;
this.mymodel.password = this.loginForm.get('password')?.value;
console.log(this.mymodel);
this.authService.login(this.mymodel).subscribe((response) => {
console.log('werkt');
const token = response.token;
this.handleToken(token);
this.router.navigate(['invoicing']);
});
}
private handleToken(token: string): void {
localStorage.setItem('token', token);
this.authService.token = token;
}```
```ts
login(loginUser: Loginmodel): Observable<any> {
return this.http
.post<any>(`${this.apiUrl}/login`, loginUser, this.getHttpOptions())
.pipe(
map((response) => {
localStorage.setItem('token', response.access_token);
return { token: response.access_token };
}),
catchError((error: HttpErrorResponse) => {
if (error.status === 409) {
const errorMessage =
'There is a problem with the token, if this keeps happening contact the server admin';
throw new Error(errorMessage);
}
throw new Error('Something went wrong');
})
);
}
i do get in the invoicing page that i want to go, just cant acces my data havving the guard
because this error
Right. And that error is due password being undefined
sad should i post some client side parts to?
I still didn't get how you manage to get the logs from validateUser method called twice
are you using some strategy from passport? I saw them in your repo but looks like users controller didn't use them
I'd investigate here
see if username and password are what you think they are, in both file above
what's the value of payload?
right, the payload is the jwt, not its the decoded value
so there's something wrong with this or with the request you're sending from the client
i am
i dont know whats wrong