moved LoginResult in types

This commit is contained in:
Djeeberjr 2021-09-24 15:54:03 +02:00
parent f59f3183f2
commit 9cfc4da5f3
3 changed files with 9 additions and 9 deletions

View File

@ -13,11 +13,6 @@ import (
types "git.kapelle.org/niklas/s3browser/internal/types"
)
type LoginResult struct {
Token string `json:"token"`
Successful bool `json:"successful"`
}
var graphqlDirType *graphql.Object
var graphqlFileType *graphql.Object
var graphqlLoginResultType *graphql.Object

View File

@ -194,11 +194,11 @@ func deleteDirectory(ctx context.Context, path string) error {
}
//login Checks for valid username password combination. Returns singed jwt string
func login(ctx context.Context, username, password string) (LoginResult, error) {
func login(ctx context.Context, username, password string) (types.LoginResult, error) {
// TODO: replace with propper user management
if username != "admin" && password != "hunter2" {
return LoginResult{
return types.LoginResult{
Successful: false,
}, nil
}
@ -208,12 +208,12 @@ func login(ctx context.Context, username, password string) (LoginResult, error)
tokenString, err := token.SignedString([]byte("TODO"))
if err != nil {
return LoginResult{
return types.LoginResult{
Successful: false,
}, err
}
return LoginResult{
return types.LoginResult{
Token: tokenString,
Successful: true,
}, nil

View File

@ -40,3 +40,8 @@ type Directory struct {
type JWTClaims struct {
jwt.StandardClaims
}
type LoginResult struct {
Token string `json:"token"`
Successful bool `json:"successful"`
}