From 9cfc4da5f32ceeaa5008cfbcab87e18ae2ba1ee3 Mon Sep 17 00:00:00 2001 From: Djeeberjr Date: Fri, 24 Sep 2021 15:54:03 +0200 Subject: [PATCH] moved LoginResult in types --- internal/gql/graphqlTypes.go | 5 ----- internal/gql/mutations.go | 8 ++++---- internal/types/types.go | 5 +++++ 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/internal/gql/graphqlTypes.go b/internal/gql/graphqlTypes.go index 17c8253..7eaa573 100644 --- a/internal/gql/graphqlTypes.go +++ b/internal/gql/graphqlTypes.go @@ -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 diff --git a/internal/gql/mutations.go b/internal/gql/mutations.go index 600c36d..6c40547 100644 --- a/internal/gql/mutations.go +++ b/internal/gql/mutations.go @@ -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 diff --git a/internal/types/types.go b/internal/types/types.go index 68c7702..0cb3a77 100644 --- a/internal/types/types.go +++ b/internal/types/types.go @@ -40,3 +40,8 @@ type Directory struct { type JWTClaims struct { jwt.StandardClaims } + +type LoginResult struct { + Token string `json:"token"` + Successful bool `json:"successful"` +}