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.
This commit is contained in:
parent
722bc539ea
commit
fe7bab183f
5 changed files with 9 additions and 8 deletions
|
@ -98,7 +98,7 @@ paths:
|
|||
application/json:
|
||||
schema:
|
||||
$ref: "#/components/schemas/AccountSigninResponse"
|
||||
/account/logout:
|
||||
/account/signout:
|
||||
post:
|
||||
tags:
|
||||
- account
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
||||
|
|
|
@ -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{
|
||||
|
|
|
@ -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{
|
||||
|
|
|
@ -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"`
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue