summaryrefslogtreecommitdiffstats
path: root/model/user.go
diff options
context:
space:
mode:
authorChristopher Speller <crspeller@gmail.com>2015-08-18 08:47:35 -0400
committerChristopher Speller <crspeller@gmail.com>2015-08-18 08:47:35 -0400
commit2f1dcf6f5267ecf85d14c8a36a9d3059a5d41218 (patch)
tree1de5578c9050a33635960fc046fdf97339254be0 /model/user.go
parent96d1eb1c800a427e31e63970e57d0824a3bc91e3 (diff)
parenta7f09be9783f3354ab38d4fb4fb82085241d018f (diff)
downloadchat-2f1dcf6f5267ecf85d14c8a36a9d3059a5d41218.tar.gz
chat-2f1dcf6f5267ecf85d14c8a36a9d3059a5d41218.tar.bz2
chat-2f1dcf6f5267ecf85d14c8a36a9d3059a5d41218.zip
Merge pull request #381 from mattermost/mm-1705
MM-1705 add google as an oauth single-sign-on service
Diffstat (limited to 'model/user.go')
-rw-r--r--model/user.go68
1 files changed, 12 insertions, 56 deletions
diff --git a/model/user.go b/model/user.go
index ed5161538..ebefa4762 100644
--- a/model/user.go
+++ b/model/user.go
@@ -8,24 +8,22 @@ import (
"encoding/json"
"io"
"regexp"
- "strconv"
"strings"
)
const (
- ROLE_ADMIN = "admin"
- ROLE_SYSTEM_ADMIN = "system_admin"
- ROLE_SYSTEM_SUPPORT = "system_support"
- USER_AWAY_TIMEOUT = 5 * 60 * 1000 // 5 minutes
- USER_OFFLINE_TIMEOUT = 1 * 60 * 1000 // 1 minute
- USER_OFFLINE = "offline"
- USER_AWAY = "away"
- USER_ONLINE = "online"
- USER_NOTIFY_ALL = "all"
- USER_NOTIFY_MENTION = "mention"
- USER_NOTIFY_NONE = "none"
- BOT_USERNAME = "valet"
- USER_AUTH_SERVICE_GITLAB = "gitlab"
+ ROLE_ADMIN = "admin"
+ ROLE_SYSTEM_ADMIN = "system_admin"
+ ROLE_SYSTEM_SUPPORT = "system_support"
+ USER_AWAY_TIMEOUT = 5 * 60 * 1000 // 5 minutes
+ USER_OFFLINE_TIMEOUT = 1 * 60 * 1000 // 1 minute
+ USER_OFFLINE = "offline"
+ USER_AWAY = "away"
+ USER_ONLINE = "online"
+ USER_NOTIFY_ALL = "all"
+ USER_NOTIFY_MENTION = "mention"
+ USER_NOTIFY_NONE = "none"
+ BOT_USERNAME = "valet"
)
type User struct {
@@ -54,13 +52,6 @@ type User struct {
FailedAttempts int `json:"failed_attempts"`
}
-type GitLabUser struct {
- Id int64 `json:"id"`
- Username string `json:"username"`
- Email string `json:"email"`
- Name string `json:"name"`
-}
-
// IsValid validates the user and returns an error if it isn't configured
// correctly.
func (u *User) IsValid() *AppError {
@@ -355,38 +346,3 @@ func IsUsernameValid(username string) bool {
return true
}
-
-func UserFromGitLabUser(glu *GitLabUser) *User {
- user := &User{}
- user.Username = glu.Username
- splitName := strings.Split(glu.Name, " ")
- if len(splitName) == 2 {
- user.FirstName = splitName[0]
- user.LastName = splitName[1]
- } else if len(splitName) >= 2 {
- user.FirstName = splitName[0]
- user.LastName = strings.Join(splitName[1:], " ")
- } else {
- user.FirstName = glu.Name
- }
- user.Email = glu.Email
- user.AuthData = strconv.FormatInt(glu.Id, 10)
- user.AuthService = USER_AUTH_SERVICE_GITLAB
-
- return user
-}
-
-func GitLabUserFromJson(data io.Reader) *GitLabUser {
- decoder := json.NewDecoder(data)
- var glu GitLabUser
- err := decoder.Decode(&glu)
- if err == nil {
- return &glu
- } else {
- return nil
- }
-}
-
-func (glu *GitLabUser) GetAuthData() string {
- return strconv.FormatInt(glu.Id, 10)
-}