authentication

package
v0.0.0-...-c12dc61 Latest Latest
Warning

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

Go to latest
Published: Jun 1, 2020 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const DB string = "./server/database.db"

DB const variable indicates the path of the sqlite3 file

Variables

This section is empty.

Functions

func CheckCookie

func CheckCookie(r *http.Request) bool

CheckCookie function checks if there is already a cookie or not

func CheckMail

func CheckMail(email string) bool

CheckMail check if mail is already exist in our db

func ClearSession

func ClearSession(w http.ResponseWriter)

ClearSession function Clears the cookie by modifying the cookie's MaxAge

func GetCookieValue

func GetCookieValue(r *http.Request) (string, error)

GetCookieValue From *http.request get the Cookie if available

func GetUsername

func GetUsername(r *http.Request) (username string)

GetUsername function takes http request as input and returns the username who was encoded before in the cookie

func Login

func Login(username string, password string) bool

Login Checks if the username and password entered are the same as others in the DB

func Register

func Register(username string, password string, email string) bool

Register Saves New Users into Sqlite DB

func SetSession

func SetSession(username string, w http.ResponseWriter) (*http.Cookie, error)

SetSession function takes username and the http response Writer as inputs Then Encode User's username and use it as a session cookie finally sets the cookie for the user otherwise it returns an error

func UpdatePassword

func UpdatePassword(email, password string) bool

UpdatePassword update user password

Types

This section is empty.

Jump to

Keyboard shortcuts

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