From e5e88d16049f4527eaab6b066c731fbe4247b574 Mon Sep 17 00:00:00 2001 From: =Corey Hulen Date: Fri, 11 Sep 2015 09:39:28 -0700 Subject: Renaming ROLE_ADMIN to ROLE_TEAM_ADMIN --- model/user.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'model') diff --git a/model/user.go b/model/user.go index 1a169f763..fdc519b99 100644 --- a/model/user.go +++ b/model/user.go @@ -13,7 +13,7 @@ import ( ) const ( - ROLE_ADMIN = "admin" + ROLE_TEAM_ADMIN = "admin" ROLE_SYSTEM_ADMIN = "system_admin" USER_AWAY_TIMEOUT = 5 * 60 * 1000 // 5 minutes USER_OFFLINE_TIMEOUT = 1 * 60 * 1000 // 1 minute @@ -289,7 +289,7 @@ func isValidRole(role string) bool { return true } - if role == ROLE_ADMIN { + if role == ROLE_TEAM_ADMIN { return true } -- cgit v1.2.3-1-g7c22 From 7b3c2d6d85ecee86fbc85b440e7028018b1090b1 Mon Sep 17 00:00:00 2001 From: Christopher Speller Date: Mon, 14 Sep 2015 12:04:57 -0400 Subject: Allowing underscores in channel names. Added conversion of some slack channel names into valid mattermost names. --- model/team.go | 2 +- model/utils.go | 12 +++++++++--- 2 files changed, 10 insertions(+), 4 deletions(-) (limited to 'model') diff --git a/model/team.go b/model/team.go index 6006f738c..8b4f82830 100644 --- a/model/team.go +++ b/model/team.go @@ -158,7 +158,7 @@ func IsReservedTeamName(s string) bool { func IsValidTeamName(s string) bool { - if !IsValidAlphaNum(s) { + if !IsValidAlphaNum(s, false) { return false } diff --git a/model/utils.go b/model/utils.go index 17d1c6317..d5122e805 100644 --- a/model/utils.go +++ b/model/utils.go @@ -202,7 +202,7 @@ func GetSubDomain(s string) (string, string) { func IsValidChannelIdentifier(s string) bool { - if !IsValidAlphaNum(s) { + if !IsValidAlphaNum(s, true) { return false } @@ -213,10 +213,16 @@ func IsValidChannelIdentifier(s string) bool { return true } +var validAlphaNumUnderscore = regexp.MustCompile(`^[a-z0-9]+([a-z\-\_0-9]+|(__)?)[a-z0-9]+$`) var validAlphaNum = regexp.MustCompile(`^[a-z0-9]+([a-z\-0-9]+|(__)?)[a-z0-9]+$`) -func IsValidAlphaNum(s string) bool { - match := validAlphaNum.MatchString(s) +func IsValidAlphaNum(s string, allowUnderscores bool) bool { + var match bool + if allowUnderscores { + match = validAlphaNumUnderscore.MatchString(s) + } else { + match = validAlphaNum.MatchString(s) + } if !match { return false -- cgit v1.2.3-1-g7c22