func GetUser(id string) (*model.User, error) { user := model.User{} err := model.GetUser(id, &user) if err != nil { return nil, err } return &user, nil }
func Login(reqLogin bodies.RequestLoginUser) (string, error) { user := model.User{} model.GetUser(reqLogin.ID, &user) if user.Password == reqLogin.Password { // Create the token token := jwt.New(jwt.SigningMethodHS256) // Set some claims token.Claims["foo"] = "bar" token.Claims["exp"] = time.Now().Add(time.Hour * 72).Unix() // Sign and get the complete encoded token as a string tokenString, err := token.SignedString(env.SecretKey) return tokenString, err } return "", errors.New("invalid user") }