api

package
v0.0.0-...-1b02ee1 Latest Latest
Warning

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

Go to latest
Published: Jan 31, 2022 License: AGPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AdminIndex

func AdminIndex(w http.ResponseWriter, r *http.Request)

func CheckPass

func CheckPass(password string, hash string) bool

func CreateRouter

func CreateRouter()

CreateRouter generates a new instance of Mux Router

func GenerateJWT

func GenerateJWT(email string, role string) (string, error)

Generate JWT Token based in the email and in the role as input. Creates a token by the algorithm signing method (HS256) and adds authorized email, role, and exp into claims. Claims are pieces of info added into the tokens.

func GeneratePass

func GeneratePass(password string) (string, error)

Generate Password from a Hash

func InitializeRoute

func InitializeRoute()

InitializeRoute creates handlers for the mux Router to handle

func SignIn

func SignIn(w http.ResponseWriter, r *http.Request)

SignIn function that checks if the user is present in the system, and check the key:values stored in the database. After compares the values from input and output and if its ok, generates a Golang JWT authentication

func SignUp

func SignUp(w http.ResponseWriter, r *http.Request)

func StartServer

func StartServer()

func UserIndex

func UserIndex(w http.ResponseWriter, r *http.Request)

Types

type Authentication

type Authentication struct {
	Email    string `json:"email"`
	Password string `json:"password"`
}

Authentication is for login data

type Error

type Error struct {
	IsError bool   `json:"isError"`
	Message string `json:"message"`
}

func SetError

func SetError(err Error, message string) Error

type Token

type Token struct {
	Role        string `json:"role"`
	Email       string `json:"email"`
	TokenString string `json:"token"`
}

Token

Jump to

Keyboard shortcuts

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