user

package
v0.0.0-...-a21a18e Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 5, 2021 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Arguments

func GetArguments

func GetArguments() Arguments

type Resolverers

type Resolverers interface {
	// Returning a list of all users from table users
	AllUsers() ([]UserType, error)

	// Get information of a single user.
	// It takes user_id from access_token
	User(params graphql.ResolveParams) (*UserType, error)

	// Login action.
	// It takes login and password from graphql.ResolveParams, looking for user by login
	// from table users, comparing hashed password from db with not hashed password from args.
	Login(params graphql.ResolveParams) (*authorization.Tokens, error)

	// Registration of new user.
	// Taking arguments from graphql.ResolveParams and storing it in table "users".
	// Returning access_token and refresh_token for login.
	Create(params graphql.ResolveParams) (*authorization.Tokens, error)

	// Update user ingormation.
	// It takes arguments from graphql.ResolvePrams, authorization key from Context
	// Extracts userId from token and stroing new data to users table.
	Update(params graphql.ResolveParams) (interface{}, error)

	// Action for logout user.
	// It takes authorization header key from graphql.ResolvePrams Context and extracting
	// values from token. Then deleting token from redis client and returning id of user
	Logout(params graphql.ResolveParams) (interface{}, error)

	// Refreshing tokens.
	// It takes refresh token from request and using authorization.RefreshToken
	RefreshToken(params graphql.ResolveParams) (*authorization.Tokens, error)
}

func GetResolvers

func GetResolvers(pgsql *sqlx.DB, client *redis.Client) Resolverers

type Resolvers

type Resolvers struct {
	RedisClient *redis.Client
	// contains filtered or unexported fields
}

func (*Resolvers) AllUsers

func (r *Resolvers) AllUsers() ([]UserType, error)

func (*Resolvers) Create

func (r *Resolvers) Create(params graphql.ResolveParams) (*authorization.Tokens, error)

func (*Resolvers) Login

func (*Resolvers) Logout

func (r *Resolvers) Logout(params graphql.ResolveParams) (interface{}, error)

func (*Resolvers) RefreshToken

func (r *Resolvers) RefreshToken(params graphql.ResolveParams) (*authorization.Tokens, error)

func (*Resolvers) Update

func (r *Resolvers) Update(params graphql.ResolveParams) (interface{}, error)

func (*Resolvers) User

func (r *Resolvers) User(params graphql.ResolveParams) (*UserType, error)

type Types

type Types struct {
	User         *graphql.Object
	Create       *graphql.Object
	Login        *graphql.Object
	Update       *graphql.Object
	Logout       *graphql.Object
	RefreshToken *graphql.Object
}

func GetTypes

func GetTypes() Types

type UserInput

type UserInput struct {
	First_name string `json:"first_name" db:"first_name"`
	Last_name  string `json:"last_name" db:"last_name"`
	Phone      string `json:"phone" db:"phone"`
	Email      string `json:"email" db:"email"`
	Login      string `json:"login" db:"login"`
	Password   string `json:"password" db:"password"`
}

struct for storing users data

type UserLogin

type UserLogin struct {
	Id       int    `json:"id" db:"id"`
	Password string `json:"password" db:"password"`
}

type UserType

type UserType struct {
	Id         int                `json:"_id"`
	Created_at string             `json:"created_at"`
	Updated_at string             `json:"updated_at"`
	First_name string             `json:"first_name" db:"first_name"`
	Last_name  string             `json:"last_name" db:"last_name"`
	Phone      string             `json:"phone" db:"phone"`
	Email      string             `json:"email" db:"email"`
	Login      string             `json:"login" db:"login"`
	Password   string             `json:"password" db:"password"`
	Last_login string             `json:"last_login" db:"last_login"`
	Payments   []payments.Payment `json:"payments"`
}

inheritance is not working for structs with graphql.ResolverFunc

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL