controller

package
v1.6.391 Latest Latest
Warning

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

Go to latest
Published: Jul 2, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package controller contains all the controllers of the application

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Activate2FA

func Activate2FA(c *gin.Context)

Activate2FA - activate 2FA upon validation

- possible for accounts without 2FA-ON

dependency: relational database, JWT, 2FA service

Accepted JSON payload:

`{"otp":"..."}`

func CreateBackup2FA

func CreateBackup2FA(c *gin.Context)

CreateBackup2FA - get new set of 2FA backup codes

- 2FA must already be enabled for the user account

dependency: relational database, JWT, 2FA service

Accepted JSON payload:

`{"password":"..."}`

func CreateUserAuth

func CreateUserAuth(c *gin.Context)

CreateUserAuth - register a new user account

[POST]: /register

dependency: relational database

Accepted JSON payload:

`{"email":"...", "password":"..."}`

func CreateVerificationEmail

func CreateVerificationEmail(c *gin.Context)

CreateVerificationEmail issues new verification code upon request

dependency: email service, email verification service, Redis

Accepted JSON payload:

`{"email":"...", "password":"..."}`

func Deactivate2FA

func Deactivate2FA(c *gin.Context)

Deactivate2FA - disable 2FA for user account

dependency: relational database, JWT, 2FA service

Accepted JSON payload:

`{"password":"..."}`

func GetUnverifiedEmail

func GetUnverifiedEmail(c *gin.Context)

GetUnverifiedEmail - if any email is yet to be verified, return it to the logged-in user

When this email is verified, it will replace the existing active email of the user.

dependency: email verification service, relational database, JWT

func Login

func Login(c *gin.Context)

Login - issue new JWTs after user:pass verification

[POST]: /login

dependency: relational database, JWT

Accepted JSON payload:

`{"email":"...", "password":"..."}`

func Logout

func Logout(c *gin.Context)

Logout -

- if 'AUTH_COOKIE_ACTIVATE=yes', delete tokens from client browser.

- if Redis is enabled, save invalid tokens in Redis up until the expiry time.

dependency: JWT

func PasswordForgot

func PasswordForgot(c *gin.Context)

PasswordForgot sends secret code for resetting a forgotten password

dependency: relational database, Redis, email service, password recovery service

Accepted JSON payload:

`{"email":"..."}`

func PasswordRecover

func PasswordRecover(c *gin.Context)

PasswordRecover resets a forgotten password

dependency: relational database, Redis

Accepted JSON payload:

`{"secretCode":"...", "passNew":"...", "passRepeat":"...", "recoveryKey":"..."}`

- `recoveryKey` is required if 2FA is enabled for the user account

func PasswordUpdate

func PasswordUpdate(c *gin.Context)

PasswordUpdate - change password in logged-in state

dependency: relational database, JWT

Accepted JSON payload:

`{"password":"...", "passNew":"...", "passRepeat":"..."}`

func Refresh

func Refresh(c *gin.Context)

Refresh - issue new JWTs after validation

dependency: JWT

func ResendVerificationCodeToModifyActiveEmail

func ResendVerificationCodeToModifyActiveEmail(c *gin.Context)

ResendVerificationCodeToModifyActiveEmail issues new verification code upon request

dependency: email service, email verification service, Redis, relational database, JWT

func Setup2FA

func Setup2FA(c *gin.Context)

Setup2FA - get secret to activate 2FA

- possible for accounts without 2FA-ON

dependency: relational database, JWT, 2FA service

Accepted JSON payload:

`{"password":"..."}`

func UpdateEmail

func UpdateEmail(c *gin.Context)

UpdateEmail - update existing user email

dependency: relational database, JWT

Accepted JSON payload:

`{"emailNew":"...", "password":"..."}`

func Validate2FA

func Validate2FA(c *gin.Context)

Validate2FA - issue new JWTs upon 2FA validation

- required for accounts with 2FA-ON

dependency: relational database, JWT, 2FA service

Accepted JSON payload:

`{"otp":"..."}`

func ValidateBackup2FA

func ValidateBackup2FA(c *gin.Context)

ValidateBackup2FA - issue new JWTs upon 2FA validation with backup code

dependency: relational database, JWT, 2FA service

Accepted JSON payload:

`{"otp":"..."}`

func VerifyEmail

func VerifyEmail(c *gin.Context)

VerifyEmail - verify email address of a newly registered user account

dependency: email verification service, Redis

Accepted JSON payload:

`{"verificationCode":"..."}`

func VerifyUpdatedEmail

func VerifyUpdatedEmail(c *gin.Context)

VerifyUpdatedEmail - verify request to modify user's email address

dependency: email verification service, relational database, redis

Accepted JSON payload:

`{"verificationCode":"..."}`

Types

This section is empty.

Jump to

Keyboard shortcuts

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