Documentation
¶
Overview ¶
Package Name: users File Name: users.go Abstract: Wrapper for exposing to fx all the components of the 'users' context.
Author: Alejandro Modroño <[email protected]> Created: 07/08/2023 Last Updated: 07/24/2023
MIT License ¶
Copyright 2023 Alejandro Modroño Vara ¶
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Package Name: auth File Name: auth_controller.go Abstract: The controller for everything related with authenticating users.
Author: Alejandro Modroño <[email protected]> Created: 07/08/2023 Last Updated: 07/24/2023
MIT License ¶
Copyright 2023 Alejandro Modroño Vara ¶
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Package Name: auth File Name: auth_routes.go Abstract: The routes for logging in and signing up.
Author: Alejandro Modroño <[email protected]> Created: 07/08/2023 Last Updated: 07/24/2023
MIT License ¶
Copyright 2023 Alejandro Modroño Vara ¶
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Package Name: auth File Name: auth_service.go Abstract: The service for verifying and creating JWTs.
Author: Alejandro Modroño <[email protected]> Created: 07/08/2023 Last Updated: 07/24/2023
MIT License ¶
Copyright 2023 Alejandro Modroño Vara ¶
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var Context = fx.Options( fx.Provide(GetAuthController), fx.Provide(GetAuthService), fx.Provide(SetAuthRoutes), )
Module exports services present
Functions ¶
func GetAuthService ¶
func GetAuthService(db *lib.Database) interfaces.AuthService
GetUserService returns the user service.
Types ¶
type AuthController ¶
type AuthController struct {
// contains filtered or unexported fields
}
AuthController struct
func GetAuthController ¶
func GetAuthController( logger lib.Logger, service interfaces.AuthService, usersService users.UsersRepository, ) AuthController
GetAuthController retrieves a new auth controller.
func (AuthController) Login ¶
func (controller AuthController) Login(ctx *gin.Context)
SignIn signs in user
func (AuthController) Signup ¶
func (controller AuthController) Signup(ctx *gin.Context)
Register registers user
type AuthRoutes ¶
type AuthRoutes struct {
// contains filtered or unexported fields
}
UserRoutes struct
func SetAuthRoutes ¶
func SetAuthRoutes( logger lib.Logger, router *lib.Router, authController AuthController, ) AuthRoutes
Returns an AuthRoutes struct.
type AuthService ¶
type AuthService struct {
// contains filtered or unexported fields
}
AuthService service layer
func (AuthService) CheckToken ¶
func (service AuthService) CheckToken(tokenString string) (*int32, error)
CheckToken checks whether the token is correct and returns the subject, which in the case of our API is supposed to be the id of the user.
func (AuthService) CreateToken ¶
func (service AuthService) CreateToken(id int32) (*string, error)
CreateToken creates jwt auth token
type SignupBody ¶
type SignupBody struct { Username string `json:"username" form:"username" binding:"required,alpha"` Email string `json:"email" form:"email" binding:"required,email"` Password string `json:"password" form:"password" binding:"required"` ConfirmPassword string `json:"confirm_password" form:"confirm_password" binding:"required,eqfield=Password"` }