auth

package
v0.0.0-...-760dedd Latest Latest
Warning

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

Go to latest
Published: Aug 23, 2018 License: MIT Imports: 9 Imported by: 0

README

Purpose

auth is used for authenticating with OAuth (Twitter only for now) and then

  • getting or storing the result in the UserStore database (storing if it's a brand new user)
  • storing the userId and username in the session cookie

It is also queried to get the currently signed in user via auth.GetUserInfo()

How to use

import "blahblah/backend/auth" import "blahblah/backend/user"

  • usp := user.NewUserStoreProvider() auth.Setup(usp)

func PageHandler(w http.ResponseWriter, r *http.Request) { user = auth.GetUserInfo(r)

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Setup

func Setup(usp userpkg.UserStoreProvider)

Types

type TwitterUserInfo

type TwitterUserInfo struct {
	Id_str      string
	Screen_name string
	Location    string
	Description string
}

type User

type User interface {
	GetUserId() string
	GetUsername() string
}

type UserInfo

type UserInfo struct {
	UserId     string
	Username   string
	IsAdmin    bool
	IsSignedIn bool
}

func GetUserInfo

func GetUserInfo(r *http.Request) UserInfo

func (UserInfo) GetIsAdmin

func (u UserInfo) GetIsAdmin() bool

func (UserInfo) GetUserId

func (u UserInfo) GetUserId() string

Jump to

Keyboard shortcuts

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