auth

package
v0.0.0-...-e1bcdf1 Latest Latest
Warning

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

Go to latest
Published: Feb 14, 2019 License: BSD-2-Clause Imports: 13 Imported by: 0

Documentation

Overview

Package auth implements user registration and authentication for chat project.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AuthenticateHandler

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

AuthenticateHandler gets user, password, redirect parameters from request and logs in the user. Response has Token session cookie. If redirect=1 redirects to /index.html.

func CreateHandler

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

CreateHandler checks if user, email and rt parameters match registration file and creates permanent user profile. Redirects to AuthenticateHandler with user and password and redirect=1 parameters

func RegisterHandler

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

RegisterHandler gets user and email parameters from request. Creates provisional user registration file and sends email to the administrator. Email has the link which should call the CreateHandler. Administrator should accept the registration by forwarding the email to the user. User should follow the link which calls CreateHandler which completes user registration.

Types

type UserAuth

type UserAuth struct {
	Name     string
	Password string
	Email    string
	Token    string // session token
}

UserAuth is a authentication record

func GetAuthUser

func GetAuthUser(token string) (user *UserAuth, err error)

GetAuthUser finds authenticated user in the list by token. TODO: Eventually should accept user id from cookie to minimize user lookup time.

Jump to

Keyboard shortcuts

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