Documentation
¶
Overview ¶
User management (sign up, login, sessions).
Index ¶
- Constants
- Variables
- func ConfirmEmail(confirmationCode string) (userDoc interface{}, email string, confirmed bool, err error)
- func EmailConfirmationView(profileURL view.URL) view.View
- func EnsureExists(username, email, password string, admin bool) (doc interface{}, exists bool, err error)
- func FindByEmail(addr string) (doc interface{}, found bool, err error)
- func FindByID(id string) (userDoc interface{}, found bool, err error)
- func Init(collection *mongo.Collection)
- func IsConfirmedUserID(id string) (confirmed bool, err error)
- func Login(session *view.Session, userDoc interface{})
- func LoginEmailPassword(session *view.Session, email, password string) (emailPasswdMatch bool, err error)
- func Logout(session *view.Session)
- func LogoutView(redirect view.URL) view.View
- func Nav(login, signup, logout, profile *view.Link, separator view.View) view.View
- func NewLoginForm(buttonText, class, errorMessageClass, successMessageClass string, ...) view.View
- func NewSignupForm(buttonText, class, errorMessageClass, successMessageClass string, ...) *view.Form
- func OfSession(session *view.Session) (userDoc interface{})
- type Auth
- type Configuration
- type ConfirmationMessage
- type EmailIdentity
- func (self *EmailIdentity) LinkContent(ctx *view.Context) view.View
- func (self *EmailIdentity) LinkRel(ctx *view.Context) string
- func (self *EmailIdentity) LinkTitle(ctx *view.Context) string
- func (self *EmailIdentity) MailtoURL() string
- func (self *EmailIdentity) SendConfirmationEmail(ctx *view.Context, confirmationURL view.URL) <-chan error
- func (self *EmailIdentity) URL(ctx *view.Context) string
- type EmailPasswordFormModel
- type FacebookIdentity
- func (self *FacebookIdentity) LinkContent(ctx *view.Context) view.View
- func (self *FacebookIdentity) LinkRel(ctx *view.Context) string
- func (self *FacebookIdentity) LinkTitle(ctx *view.Context) string
- func (self *FacebookIdentity) ProfileURL() string
- func (self *FacebookIdentity) URL(ctx *view.Context) string
- type GitHubIdentity
- func (self *GitHubIdentity) LinkContent(ctx *view.Context) view.View
- func (self *GitHubIdentity) LinkRel(ctx *view.Context) string
- func (self *GitHubIdentity) LinkTitle(ctx *view.Context) string
- func (self *GitHubIdentity) ProfileURL() string
- func (self *GitHubIdentity) URL(ctx *view.Context) string
- type LinkedInIdentity
- func (self *LinkedInIdentity) LinkContent(ctx *view.Context) view.View
- func (self *LinkedInIdentity) LinkRel(ctx *view.Context) string
- func (self *LinkedInIdentity) LinkTitle(ctx *view.Context) string
- func (self *LinkedInIdentity) ProfileURL() string
- func (self *LinkedInIdentity) URL(ctx *view.Context) string
- type LoginFormModel
- type PasswordFormModel
- type PhoneNumber
- type SkypeIdentity
- type TwitterIdentity
- func (self *TwitterIdentity) LinkContent(ctx *view.Context) view.View
- func (self *TwitterIdentity) LinkRel(ctx *view.Context) string
- func (self *TwitterIdentity) LinkTitle(ctx *view.Context) string
- func (self *TwitterIdentity) ProfileURL() string
- func (self *TwitterIdentity) URL(ctx *view.Context) string
- type User
- func (self *User) AddEmail(address, description string) (err error)
- func (self *User) AddPhone(number, description string)
- func (self *User) ConfirmEmailPassword()
- func (self *User) EmailConfirmed(email string) bool
- func (self *User) EmailPasswordConfirmed() bool
- func (self *User) EmailPasswordMatch(email, password string) bool
- func (self *User) FacebookIdentityConfirmed() bool
- func (self *User) HasEmail(address string) bool
- func (self *User) HasPhone(number string) bool
- func (self *User) IdentityConfirmed() bool
- func (self *User) LinkedInIdentityConfirmed() bool
- func (self *User) PrimaryEmail() string
- func (self *User) PrimaryEmailIdentity() *EmailIdentity
- func (self *User) PrimaryFacebookIdentity() *FacebookIdentity
- func (self *User) PrimaryGitHubIdentity() *GitHubIdentity
- func (self *User) PrimaryLinkedInIdentity() *LinkedInIdentity
- func (self *User) PrimaryPhone() string
- func (self *User) PrimarySkypeIdentity() *SkypeIdentity
- func (self *User) PrimaryTwitterIdentity() *TwitterIdentity
- func (self *User) PrimaryWeb() string
- func (self *User) PrimaryXingIdentity() *XingIdentity
- func (self *User) TwitterIdentityConfirmed() bool
- type Website
- type XingIdentity
Constants ¶
const ContextCacheKey = "github.com/ungerik/go-start/user.ContextCacheKey"
Variables ¶
var ( UserPtrType = reflect.TypeOf((*User)(nil)) UserType = UserPtrType.Elem() )
var Config = Configuration{ ConfirmationMessage: ConfirmationMessage{ EmailSubject: "Please confirm your email address for %s", EmailMessage: "Please confirm your email address for %s by opening the following link:\n\n%s", Sent: "We sent you an email with a verification link.<br/>It might some time to show up, but when it does you will be ready to use this site.", }, }
Functions ¶
func ConfirmEmail ¶
func EmailConfirmationView ¶
The confirmation code will be passed in the GET parameter "code"
func EnsureExists ¶
func EnsureExists(username, email, password string, admin bool) (doc interface{}, exists bool, err error)
Will use user.User.Username for search Sets the username also as first name
func FindByEmail ¶
func Init ¶
func Init(collection *mongo.Collection)
func IsConfirmedUserID ¶
func LoginEmailPassword ¶
func LogoutView ¶
If redirect is nil, the redirect will go to "/"
func Nav ¶
Nav returns user navigation links depending on if there is an user session. If a user session is active, logout and profile will be returned, if there is no active user session, login and signup will be returned. separator will be put between the returned links. signup, profile, and separator are optional and can be nil.
func NewLoginForm ¶
Types ¶
type Configuration ¶
type Configuration struct { ConfirmationMessage ConfirmationMessage CollectionName string Collection *mongo.Collection }
func (*Configuration) Close ¶
func (self *Configuration) Close() error
func (*Configuration) Init ¶
func (self *Configuration) Init() error
func (*Configuration) Name ¶
func (self *Configuration) Name() string
type ConfirmationMessage ¶
type EmailIdentity ¶
type EmailIdentity struct { // mongo.SubDocumentBase Address model.Email Description model.String Confirmed model.DateTime ConfirmationCode model.String }
func (*EmailIdentity) LinkContent ¶
func (self *EmailIdentity) LinkContent(ctx *view.Context) view.View
func (*EmailIdentity) MailtoURL ¶
func (self *EmailIdentity) MailtoURL() string
func (*EmailIdentity) SendConfirmationEmail ¶
func (self *EmailIdentity) SendConfirmationEmail(ctx *view.Context, confirmationURL view.URL) <-chan error
EmailIdentity has to be saved after a successful call because the confirmation code could have changed confirmationPage needs to be a page with one URL parameter
type EmailPasswordFormModel ¶
type EmailPasswordFormModel struct { Email model.Email `model:"required" view:"size=20"` PasswordFormModel `bson:",inline" view:"size=20"` }
type FacebookIdentity ¶
type FacebookIdentity struct { ID model.String Name model.String `view:"placeholder=your facebook url"` Confirmed model.DateTime AccessToken model.String }
func (*FacebookIdentity) LinkContent ¶
func (self *FacebookIdentity) LinkContent(ctx *view.Context) view.View
func (*FacebookIdentity) LinkTitle ¶
func (self *FacebookIdentity) LinkTitle(ctx *view.Context) string
func (*FacebookIdentity) ProfileURL ¶
func (self *FacebookIdentity) ProfileURL() string
type GitHubIdentity ¶
type GitHubIdentity struct { ID model.String Name model.String Confirmed model.DateTime AccessToken model.String }
func (*GitHubIdentity) LinkContent ¶
func (self *GitHubIdentity) LinkContent(ctx *view.Context) view.View
func (*GitHubIdentity) ProfileURL ¶
func (self *GitHubIdentity) ProfileURL() string
type LinkedInIdentity ¶
type LinkedInIdentity struct { ID model.String Name model.String Confirmed model.DateTime AccessToken model.String }
func (*LinkedInIdentity) LinkContent ¶
func (self *LinkedInIdentity) LinkContent(ctx *view.Context) view.View
func (*LinkedInIdentity) LinkTitle ¶
func (self *LinkedInIdentity) LinkTitle(ctx *view.Context) string
func (*LinkedInIdentity) ProfileURL ¶
func (self *LinkedInIdentity) ProfileURL() string
type LoginFormModel ¶
type PasswordFormModel ¶
type SkypeIdentity ¶
func (*SkypeIdentity) CallURL ¶
func (self *SkypeIdentity) CallURL() string
func (*SkypeIdentity) LinkContent ¶
func (self *SkypeIdentity) LinkContent(ctx *view.Context) view.View
type TwitterIdentity ¶
type TwitterIdentity struct { ID model.String Name model.String Confirmed model.DateTime AccessToken model.String }
func (*TwitterIdentity) LinkContent ¶
func (self *TwitterIdentity) LinkContent(ctx *view.Context) view.View
func (*TwitterIdentity) LinkTitle ¶
func (self *TwitterIdentity) LinkTitle(ctx *view.Context) string
func (*TwitterIdentity) ProfileURL ¶
func (self *TwitterIdentity) ProfileURL() string
type User ¶
type User struct { mongo.DocumentBase `bson:",inline"` Name modelext.Name Username model.String `view:"size=20"` Password model.Password Blocked model.Bool Admin model.Bool PostalAddress modelext.PostalAddress `view:"label=Postal Address"` Phone []PhoneNumber Web []Website Email []EmailIdentity Facebook []FacebookIdentity Twitter []TwitterIdentity LinkedIn []LinkedInIdentity Xing []XingIdentity GitHub []GitHubIdentity Skype []SkypeIdentity }
func (*User) ConfirmEmailPassword ¶
func (self *User) ConfirmEmailPassword()
func (*User) EmailConfirmed ¶
func (*User) EmailPasswordConfirmed ¶
One email address has to be confirmed and the password must not be empty
func (*User) EmailPasswordMatch ¶
func (*User) FacebookIdentityConfirmed ¶
func (*User) IdentityConfirmed ¶
func (*User) LinkedInIdentityConfirmed ¶
func (*User) PrimaryEmail ¶
func (*User) PrimaryEmailIdentity ¶
func (self *User) PrimaryEmailIdentity() *EmailIdentity
func (*User) PrimaryFacebookIdentity ¶
func (self *User) PrimaryFacebookIdentity() *FacebookIdentity
func (*User) PrimaryGitHubIdentity ¶
func (self *User) PrimaryGitHubIdentity() *GitHubIdentity
func (*User) PrimaryLinkedInIdentity ¶
func (self *User) PrimaryLinkedInIdentity() *LinkedInIdentity
func (*User) PrimaryPhone ¶
func (*User) PrimarySkypeIdentity ¶
func (self *User) PrimarySkypeIdentity() *SkypeIdentity
func (*User) PrimaryTwitterIdentity ¶
func (self *User) PrimaryTwitterIdentity() *TwitterIdentity
func (*User) PrimaryWeb ¶
func (*User) PrimaryXingIdentity ¶
func (self *User) PrimaryXingIdentity() *XingIdentity
func (*User) TwitterIdentityConfirmed ¶
type Website ¶
type Website struct { Url model.Url `view:"label=URL"` Title model.String Description model.String }
Implements view.LinkModel
type XingIdentity ¶
func (*XingIdentity) LinkContent ¶
func (self *XingIdentity) LinkContent(ctx *view.Context) view.View
func (*XingIdentity) ProfileURL ¶
func (self *XingIdentity) ProfileURL() string