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
a3e044dec5
commit
e45241fa20
5 changed files with 9 additions and 8 deletions
|
@ -98,7 +98,7 @@ paths:
|
||||||
application/json:
|
application/json:
|
||||||
schema:
|
schema:
|
||||||
$ref: "#/components/schemas/AccountSigninResponse"
|
$ref: "#/components/schemas/AccountSigninResponse"
|
||||||
/account/logout:
|
/account/signout:
|
||||||
post:
|
post:
|
||||||
tags:
|
tags:
|
||||||
- account
|
- account
|
||||||
|
|
|
@ -90,6 +90,7 @@ func AccountVerify_Service(ctx iris.Context, req types.AccountVerifyRequest) {
|
||||||
ctx.JSON(types.CommonErrorResponse{
|
ctx.JSON(types.CommonErrorResponse{
|
||||||
Error: "Something went wrong, please try again",
|
Error: "Something went wrong, please try again",
|
||||||
})
|
})
|
||||||
|
logboi.Err("Failed to commit transaction: " + err.Error())
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -33,9 +33,9 @@ import (
|
||||||
|
|
||||||
// UsersGetByUuid_Service gets all users from the database by uuid
|
// UsersGetByUuid_Service gets all users from the database by uuid
|
||||||
func UsersGetByUuid_Service(ctx iris.Context) {
|
func UsersGetByUuid_Service(ctx iris.Context) {
|
||||||
// Get user ID from URL parameters
|
// Get user UUID from URL parameters
|
||||||
uuid, err := ctx.Params().GetUint64("uuid")
|
uuid := ctx.Params().GetString("uuid")
|
||||||
if err != nil {
|
if uuid != "" {
|
||||||
ctx.StatusCode(iris.StatusBadRequest)
|
ctx.StatusCode(iris.StatusBadRequest)
|
||||||
ctx.JSON(types.CommonErrorResponse{
|
ctx.JSON(types.CommonErrorResponse{
|
||||||
Error: "Invalid uuid parameter",
|
Error: "Invalid uuid parameter",
|
||||||
|
@ -45,7 +45,7 @@ func UsersGetByUuid_Service(ctx iris.Context) {
|
||||||
|
|
||||||
// Get user from database
|
// Get user from database
|
||||||
var user db.User
|
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 {
|
if err != nil {
|
||||||
ctx.StatusCode(iris.StatusInternalServerError)
|
ctx.StatusCode(iris.StatusInternalServerError)
|
||||||
ctx.JSON(types.CommonErrorResponse{
|
ctx.JSON(types.CommonErrorResponse{
|
||||||
|
|
|
@ -39,8 +39,8 @@ func UsersGetSelf_Service(ctx iris.Context) {
|
||||||
id := claims.UserId
|
id := claims.UserId
|
||||||
|
|
||||||
// Get user from database
|
// Get user from database
|
||||||
var user []db.User
|
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
|
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 {
|
if err != nil {
|
||||||
ctx.StatusCode(iris.StatusInternalServerError)
|
ctx.StatusCode(iris.StatusInternalServerError)
|
||||||
ctx.JSON(types.CommonErrorResponse{
|
ctx.JSON(types.CommonErrorResponse{
|
||||||
|
|
|
@ -37,7 +37,7 @@ type User struct {
|
||||||
Uuid string `json:"uuid"`
|
Uuid string `json:"uuid"`
|
||||||
Role string `json:"role"`
|
Role string `json:"role"`
|
||||||
Friends Friends `gorm:"type:VARCHAR(255)" json:"friends"`
|
Friends Friends `gorm:"type:VARCHAR(255)" json:"friends"`
|
||||||
Hash string `json:"hash"`
|
Hash string `json:"hash,omitempty"`
|
||||||
Verified bool `json:"verified"`
|
Verified bool `json:"verified"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue