diff --git a/back/src/users/users.service.ts b/back/src/users/users.service.ts index bd19078..0284a8f 100644 --- a/back/src/users/users.service.ts +++ b/back/src/users/users.service.ts @@ -56,6 +56,10 @@ export class UsersService { data: Prisma.UserUpdateInput; }): Promise { const { where, data } = params; + if (typeof data.password === 'string') + data.password = await bcrypt.hash(data.password, 8); + else if (data.password && data.password.set) + data.password = await bcrypt.hash(data.password.set, 8); return this.prisma.user.update({ data, where, diff --git a/back/test/robot/auth/auth.robot b/back/test/robot/auth/auth.robot index 08a7273..ba19b5b 100644 --- a/back/test/robot/auth/auth.robot +++ b/back/test/robot/auth/auth.robot @@ -59,3 +59,44 @@ Login Should Be Equal As Strings ${res["body"]} ${me["body"]} [Teardown] DELETE /auth/me + +LoginAsGuest + [Documentation] Login as a guest + &{res}= POST /auth/guest + Output + Integer response status 200 + String response body access_token + Set Headers {"Authorization": "Bearer ${res.body.access_token}"} + + ${res}= GET /auth/me + Output + Integer response status 200 + Boolean response body isGuest true + + [Teardown] DELETE /auth/me + +GuestToNormal + [Documentation] Login as a guest and convert to a normal account + &{res}= POST /auth/guest + Output + Integer response status 200 + String response body access_token + Set Headers {"Authorization": "Bearer ${res.body.access_token}"} + + ${res}= GET /auth/me + Output + Integer response status 200 + Boolean response body isGuest true + + ${res}= PUT /auth/me { "username": "toto", "passord": "toto", "email": "a@b.c"} + Output + Integer response status 200 + Boolean response body isGuest true + + ${res}= GET /auth/me + Output + Integer response status 200 + String response body username "toto" + Boolean response body isGuest false + + [Teardown] DELETE /auth/me