Auth: Removed session/auth system from GraphQL API
This commit is contained in:
@@ -1,26 +0,0 @@
|
||||
package mutations
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"git.aiterp.net/rpdata/api/graphql/resolver/types"
|
||||
"git.aiterp.net/rpdata/api/internal/session"
|
||||
)
|
||||
|
||||
// LoginArgs is args for the login mutation
|
||||
type LoginArgs struct {
|
||||
Username string
|
||||
Password string
|
||||
}
|
||||
|
||||
// Login resolves the login mutation
|
||||
func (r *MutationResolver) Login(ctx context.Context, args *LoginArgs) (*types.SessionResolver, error) {
|
||||
session := session.FromContext(ctx)
|
||||
|
||||
err := session.Login(args.Username, args.Password)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &types.SessionResolver{S: session}, nil
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
package mutations
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"git.aiterp.net/rpdata/api/graphql/resolver/types"
|
||||
"git.aiterp.net/rpdata/api/internal/session"
|
||||
)
|
||||
|
||||
// Logout resolves mutation.logout
|
||||
func (r *MutationResolver) Logout(ctx context.Context) (*types.SessionResolver, error) {
|
||||
session := session.FromContext(ctx)
|
||||
session.Logout()
|
||||
|
||||
return &types.SessionResolver{S: session}, nil
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
package queries
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"git.aiterp.net/rpdata/api/graphql/resolver/types"
|
||||
"git.aiterp.net/rpdata/api/internal/session"
|
||||
)
|
||||
|
||||
// Session resolves query.session
|
||||
func (r *QueryResolver) Session(ctx context.Context) (*types.SessionResolver, error) {
|
||||
return &types.SessionResolver{S: session.FromContext(ctx)}, nil
|
||||
}
|
||||
@@ -49,10 +49,6 @@ type Query {
|
||||
|
||||
# Find all distinct tags used in stories
|
||||
tags: [Tag!]!
|
||||
|
||||
|
||||
# Find current session
|
||||
session: Session!
|
||||
}
|
||||
|
||||
# The Mutation type represents write entry points into the API.
|
||||
@@ -137,13 +133,6 @@ type Mutation {
|
||||
|
||||
# Remove a chapter
|
||||
removeChapter(id: String!): Chapter!
|
||||
|
||||
|
||||
# Log in
|
||||
login(username: String!, password: String!): Session!
|
||||
|
||||
# Log out
|
||||
logout(): Session!
|
||||
}
|
||||
|
||||
schema {
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
# The session represents the current login state
|
||||
type Session {
|
||||
# The user that is logged in, null if not logged in
|
||||
user: User
|
||||
}
|
||||
Reference in New Issue
Block a user