Skip to content

PR de correção#4

Open
jvpalves wants to merge 6 commits intocorrecao-projetofrom
master
Open

PR de correção#4
jvpalves wants to merge 6 commits intocorrecao-projetofrom
master

Conversation

@jvpalves
Copy link

@jvpalves jvpalves commented Sep 9, 2020

Avaliação do projeto

Copy link
Author

@jvpalves jvpalves left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oi, gente! Deixei alguns comentários ao longo do código. Em linhas gerais, o código de vocês está bem organizado, e dá para se encontrar bem, com pastas e arquivos bem organizados. No entanto, existe um tanto de código escrito que não está sendo usado, ou está com nomes repetidos, então eu tomaria um pouco mais de cuidado com essa parte. Em todo caso, a arquitetura parece estar bem montada e foi bem fácil navegar. Boa, galera!

import { User } from "../model/User";
import { Authenticator } from "../services/Authenticator";

export class UserBusiness {
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Por aqui acabou que a Friendship Business ficou com o mesmo nome da classe UserBusiness

Comment on lines +24 to +32
await userDb.createUser(user);

const accessToken = new Authenticator().generateToken({
id: user.getId(),
email: user.getEmail(),
});

return { id: id, accessToken };
}
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Muito bom!

Comment on lines +35 to +36
console.log("email - business", email);
console.log("senha - business", password);
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lembrar de remover o console.log

Comment on lines +47 to +62
const user = await userDb.getUserByEmail(email);
console.log("user que veio do banco", user);

if (!user) {
throw new Error("User not found");
}

const isPasswordCorrect = await new HashManager().compareHash(
password,
user.getPassword()
);
console.log("validação da senha: ", isPasswordCorrect);

if (!isPasswordCorrect) {
throw new Error("Wrong password");
}
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bons tratamentos de exceção aqui. Mas cuidado com os console.log

Comment on lines +9 to +32
export const getUserProfile = async (
req: Request,
res: Response
): Promise<any> => {
try {
const token = req.headers.authorization as string;

const authenticator = new Authenticator();
const authenticationData = authenticator.getData(token);

const userDatabase = new UserDatabase();
const user = await userDatabase.getUserById(authenticationData.id);

res
.status(200)
.send({ message: `success`, id: user.id, email: user.email });
} catch (error) {
res
.status(400)
.send({ message: error.message, sqlMessage: error.sqlMessage });
} finally {
await BaseDatabase.destroyConnection();
}
};
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Quando este endpoint é usado? Não consegui encontrar

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants