本文整理汇总了Golang中github.com/catalyzeio/catalyze/models.Settings.UsersID方法的典型用法代码示例。如果您正苦于以下问题:Golang Settings.UsersID方法的具体用法?Golang Settings.UsersID怎么用?Golang Settings.UsersID使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/catalyzeio/catalyze/models.Settings
的用法示例。
在下文中一共展示了Settings.UsersID方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: verify
// verify tests whether or not the given session token is still valid
func verify(settings *models.Settings) bool {
resp := httpclient.Get(fmt.Sprintf("%s/v2/auth/verify", settings.BaasHost), false, settings)
m := make(map[string]string)
json.Unmarshal(resp, &m)
// the verify route returns userId and not usersId like everything else...
if m["userId"] != "" {
settings.UsersID = m["userId"]
}
return m["userId"] != ""
}
示例2: SignIn
// SignIn signs in the user and retrieves a session. The passed in Settings
// object is updated with the most up to date credentials
func SignIn(settings *models.Settings) {
// if we're already signed in with a valid session, don't sign in again
if verify(settings) {
return
}
if settings.Username == "" || settings.Password == "" {
promptForCredentials(settings)
}
login := models.Login{
Username: settings.Username,
Password: settings.Password,
}
b, err := json.Marshal(login)
if err != nil {
fmt.Println(err.Error())
os.Exit(1)
}
resp := httpclient.Post(b, fmt.Sprintf("%s/v2/auth/signin", settings.BaasHost), true, settings)
var user models.User
json.Unmarshal(resp, &user)
settings.SessionToken = user.SessionToken
settings.UsersID = user.UsersID
config.SaveSettings(settings)
}
示例3: Logout
// Logout clears the stored user information from the local machine. This does
// not remove environment data.
func Logout(settings *models.Settings) {
settings.SessionToken = ""
settings.UsersID = ""
config.SaveSettings(settings)
}