all repos — quartzgun @ cd06fc04864bf9c0fa9156af013bf9b6572ad76e

lightweight web framework in go

auth/auth.go (raw)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
package auth

import (
  "time"
)

type User struct {
  Name string
  Pass string
  Session string
  LoginTime time.Time
  LastSeen time.Time

  Data map[string]interface{}
}

type UserStore interface {
  InitiateSession(user string, password string) (string, error)
  ValidateUser(user string, sessionId string) (bool, error)
  EndSession(user string) error
  AddUser(user string, password string) error
  DeleteUser(user string) error
  ChangePassword(user string, oldPassword string, newPassword string) error
}

func Login(user string, password string, userStore UserStore) (string, error) {
  //ValidateUser (check user exists, hash and compare password)
  //InitiateUserSession (generate token and assign it to the user)
  //set username in cookie
  //return token, nil
  return "", nil
}