feat: refactor auth package and add get users for staff
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
package userrepository
|
||||
|
||||
import (
|
||||
"errors"
|
||||
userdomain "legalgo-BE-go/internal/domain/user"
|
||||
)
|
||||
|
||||
func (ur *accessor) GetUserProfile(email string) (*userdomain.UserProfile, error) {
|
||||
var user *userdomain.User
|
||||
|
||||
if email == "" {
|
||||
return nil, errors.New("email is empty")
|
||||
}
|
||||
|
||||
if err := ur.db.
|
||||
Preload("Subscribe").
|
||||
Preload("Subscribe.SubscribePlan").
|
||||
First(&user, "email = ?", email).
|
||||
Error; err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
userProfile := &userdomain.UserProfile{
|
||||
ID: user.ID,
|
||||
Email: user.Email,
|
||||
Phone: user.Phone,
|
||||
Subscribe: user.Subscribe,
|
||||
}
|
||||
|
||||
return userProfile, nil
|
||||
}
|
||||
Reference in New Issue
Block a user