Documentation ¶
Overview ¶
Package classification Login API
Documentation for login API ¶
schemes: http BasePath: / Version: 1.0.0 Contact: natverior1@gmail.com
Consumes: - application/json
Produces: - application/json
swagger:meta
Index ¶
- Variables
- func CreateToken(db *Sessiondb, user models.UserCredentials) (token string)
- func JsonError(w *http.ResponseWriter, ErrorMessage string, ErrorCode int)
- type LoginBadRequestWrapper
- type LoginCredentials
- type LoginIncorrectPasswordWrapper
- type LoginResponse
- type LoginResponseNotFoundWrapper
- type LoginResponseWrapper
- type MyStdResp
- type Sessiondb
- type Tk
Constants ¶
This section is empty.
Variables ¶
var Mutex sync.Mutex
Functions ¶
func CreateToken ¶
func CreateToken(db *Sessiondb, user models.UserCredentials) (token string)
creates a token for a user { we should store user tokens in a redis database }
Types ¶
type LoginBadRequestWrapper ¶
type LoginBadRequestWrapper struct { //returns when the request does not conform to login api //in: body Body MyStdResp }
request does not conform to login api swagger:response loginBadRequest
type LoginCredentials ¶
type LoginCredentials struct { //user's email address Email string `json:"email"` //user's password PassWord string `json:"password"` }
swagger:model
type LoginIncorrectPasswordWrapper ¶
type LoginIncorrectPasswordWrapper struct { //returns when user enters an incorrect password //in: body Body MyStdResp }
Incorrect password swagger:response loginIncorrectPassword
type LoginResponse ¶
type LoginResponse struct { // shows if process was successful or not Status bool `json:"status"` // Contains user information Message struct { // the user's first name FirstName string `json:"firstname" validate:"required"` // the user's last name LastName string `json:"lastname" validate:"required"` // the user's email address Email string `json:"email" validate:"required"` // the user's hashed password PassWord string `json:"password" validate:"required"` // the user's id ID string `json:"id"` } `json:"message"` // A unique number that defines authenticates the users transactions Token string `json:"token"` }
LoginResponse defines the struct for API login swagger:model
type LoginResponseNotFoundWrapper ¶
type LoginResponseNotFoundWrapper struct { //returns when a non registered user tries to login //in: body Body MyStdResp }
Non registered user tries to login swagger:response loginNotFound
type LoginResponseWrapper ¶
type LoginResponseWrapper struct { //in: body Body LoginResponse }
Successful login request swagger:response loginResponse
type MyStdResp ¶
type MyStdResp struct { // successful / not successful Status bool `json:"status` // string Message string `json:"message"` }
swagger:model
type Sessiondb ¶
Sessiondb is a http.Handler
func (*Sessiondb) Login ¶
func (db *Sessiondb) Login(w http.ResponseWriter, req *http.Request)
swagger:route POST /user/login session login Returns a session token responses: 200: loginResponse 400: loginBadRequest 404: loginIncorrectPassword && loginNotFound Login returns a token and user details from the user data