aboutsummaryrefslogtreecommitdiff
path: root/user/controller.go
diff options
context:
space:
mode:
Diffstat (limited to 'user/controller.go')
-rw-r--r--user/controller.go27
1 files changed, 20 insertions, 7 deletions
diff --git a/user/controller.go b/user/controller.go
index 4933ea3..15061cc 100644
--- a/user/controller.go
+++ b/user/controller.go
@@ -1,5 +1,5 @@
/* openbills - Server for web based Libre Billing Software
- * Copyright (C) 2023 Vidhu Kant Sharma <vidhukant@vidhukant.com>
+ * Copyright (C) 2023-2024 Vidhu Kant Sharma <vidhukant@vidhukant.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -18,6 +18,7 @@
package user
import (
+ e "vidhukant.com/openbills/errors"
"github.com/gin-gonic/gin"
"net/http"
)
@@ -25,12 +26,24 @@ import (
func handleGetUser (ctx *gin.Context) {
var user User
- //err = getUser(&user, uint(id))
- //if err != nil {
- // ctx.Error(err)
- // ctx.Abort()
- // return
- //}
+ uId, ok := ctx.Get("UserID")
+ if !ok {
+ ctx.Error(e.ErrUnauthorized)
+ ctx.Abort()
+ return
+ }
+
+ userId := uId.(uint)
+
+ err := GetUser(&user, userId)
+ if err != nil {
+ ctx.Error(err)
+ ctx.Abort()
+ return
+ }
+
+ // remove password hash from response
+ user.Password = ""
ctx.JSON(http.StatusOK, gin.H{
"message": "success",