mirror of https://github.com/veypi/OneAuth.git
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
27 lines
621 B
Go
27 lines
621 B
Go
package app_user
|
|
|
|
import (
|
|
"github.com/veypi/OneAuth/cfg"
|
|
"github.com/veypi/OneAuth/models"
|
|
"github.com/veypi/OneBD/rest"
|
|
)
|
|
|
|
var _ = Router.Get("/:user_id", getAppUser)
|
|
|
|
func getAppUser(x *rest.X) (any, error) {
|
|
appID := x.Params.Get("app_id")
|
|
userID := x.Params.Get("user_id")
|
|
|
|
if appID == "" || userID == "" {
|
|
return nil, rest.NewError("app_id or user_id is empty").WithCode(400)
|
|
}
|
|
|
|
appUser := &models.AppUser{}
|
|
err := cfg.DB().Where("app_id = ? AND user_id = ?", appID, userID).First(appUser).Error
|
|
if err != nil {
|
|
return nil, rest.NewError("app_user not found").WithCode(404)
|
|
}
|
|
|
|
return appUser, nil
|
|
}
|