Skip to content

Commit

Permalink
feat: supper user PP by dicebear
Browse files Browse the repository at this point in the history
  • Loading branch information
Angel-Dijoux committed Jan 28, 2024
1 parent 475686f commit 4ac3fa2
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 2 deletions.
19 changes: 19 additions & 0 deletions bruno_onisep_explorer/createUser.bru
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
meta {
name: createUser
type: http
seq: 4
}

post {
url: http://localhost:5005/api/v1/auth/register
body: json
auth: none
}

body:json {
{
"username": "ELki",
"email": "[email protected]",
"password": "elki12345"
}
}
15 changes: 15 additions & 0 deletions bruno_onisep_explorer/getUserInformations.bru
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
meta {
name: getUserInformations
type: http
seq: 5
}

get {
url:
body: none
auth: none
}

headers {
Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJmcmVzaCI6ZmFsc2UsImlhdCI6MTcwNjQ3NTcwOCwianRpIjoiMDRiNDQ4ZmUtZTJjMy00OGY5LWE0OGEtOTczMzExNzczZjQxIiwidHlwZSI6ImFjY2VzcyIsInN1YiI6MSwibmJmIjoxNzA2NDc1NzA4LCJleHAiOjE3MDY0NzY2MDh9.UVPrRsVrOxV6mjprxD4yNIr98S5Jy_K-f7fouKcvDCQ
}
18 changes: 18 additions & 0 deletions bruno_onisep_explorer/getUserToken.bru
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
meta {
name: getUserToken
type: http
seq: 3
}

post {
url: http://localhost:5005/api/v1/auth/login
body: json
auth: none
}

body:json {
{
"username": "ELki",
"password": "elki12345"
}
}
17 changes: 15 additions & 2 deletions src/blueprints/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,16 @@ def register() -> Tuple[Response, int]:
# Hash password
pwd_hash = generate_password_hash(password)

user = User(username=username, password=pwd_hash, email=email)
user_profile_picture = (
f"https://api.dicebear.com/7.x/notionists-neutral/svg?seed='{email}'"
)

user = User(
username=username,
password=pwd_hash,
email=email,
profile_pic_url=user_profile_picture,
)
db.session.add(user)
db.session.commit()

Expand Down Expand Up @@ -119,7 +128,11 @@ def login() -> Tuple[Response, int] | HTTPException:
def me() -> Tuple[Response, int]:
user_id = get_jwt_identity()

user = db.session.query(User).filter_by(id=user_id).first()
user: User = db.session.query(User).filter_by(id=user_id).first()
if user.profile_pic_url is None:
user.profile_pic_url = (
f"https://api.dicebear.com/7.x/notionists-neutral/svg?seed='{user.email}'"
)

return (
jsonify(user),
Expand Down

0 comments on commit 4ac3fa2

Please sign in to comment.