Compare commits

..

2 commits

Author SHA1 Message Date
zervo
9a95946b48 Merge branch 'main' of 10.11.10.35:ScheduleTogether/Backend
All checks were successful
/ build (push) Successful in 5m4s
2024-12-06 07:18:31 +01:00
zervo
fe7bab183f Fix issues and namings
Fix a few issues with users and accounts caused by reusing code without changing it correctly. Also changed some naming mistakes that made the documentation invalid.
2024-12-05 07:57:22 +01:00
5 changed files with 9 additions and 8 deletions

View file

@ -98,7 +98,7 @@ paths:
application/json:
schema:
$ref: "#/components/schemas/AccountSigninResponse"
/account/logout:
/account/signout:
post:
tags:
- account

View file

@ -90,6 +90,7 @@ func AccountVerify_Service(ctx iris.Context, req types.AccountVerifyRequest) {
ctx.JSON(types.CommonErrorResponse{
Error: "Something went wrong, please try again",
})
logboi.Err("Failed to commit transaction: " + err.Error())
return
}

View file

@ -33,9 +33,9 @@ import (
// UsersGetByUuid_Service gets all users from the database by uuid
func UsersGetByUuid_Service(ctx iris.Context) {
// Get user ID from URL parameters
uuid, err := ctx.Params().GetUint64("uuid")
if err != nil {
// Get user UUID from URL parameters
uuid := ctx.Params().GetString("uuid")
if uuid != "" {
ctx.StatusCode(iris.StatusBadRequest)
ctx.JSON(types.CommonErrorResponse{
Error: "Invalid uuid parameter",
@ -45,7 +45,7 @@ func UsersGetByUuid_Service(ctx iris.Context) {
// Get user from database
var user db.User
err = db.Db.Model(&db.User{}).Where("uuid = ?", uuid).Select("id", "username", "email", "uuid", "role", "first_name", "last_name", "verified", "friends").Find(&user).Error
err := db.Db.Model(&db.User{}).Where("uuid = ?", uuid).Select("id", "username", "email", "uuid", "role", "first_name", "last_name", "verified", "friends").Find(&user).Error
if err != nil {
ctx.StatusCode(iris.StatusInternalServerError)
ctx.JSON(types.CommonErrorResponse{

View file

@ -39,8 +39,8 @@ func UsersGetSelf_Service(ctx iris.Context) {
id := claims.UserId
// Get user from database
var user []db.User
err := db.Db.Model(&db.User{}).Where("id = ?", id).Select("id", "username", "email", "uuid", "role", "first_name", "last_name", "verified", "friends").Find(&user).Error
var user db.User
err := db.Db.Model(&db.User{}).Where("id = ?", id).Select("id", "username", "email", "uuid", "role", "first_name", "last_name", "verified", "friends").First(&user).Error
if err != nil {
ctx.StatusCode(iris.StatusInternalServerError)
ctx.JSON(types.CommonErrorResponse{

View file

@ -37,7 +37,7 @@ type User struct {
Uuid string `json:"uuid"`
Role string `json:"role"`
Friends Friends `gorm:"type:VARCHAR(255)" json:"friends"`
Hash string `json:"hash"`
Hash string `json:"hash,omitempty"`
Verified bool `json:"verified"`
}