Requiring team admin to import and fixing a few style issues

This commit is contained in:
Christopher Speller
2015-08-18 11:53:18 -04:00
parent a7e935af9c
commit 9222e191aa
3 changed files with 5 additions and 9 deletions

View File

@@ -24,7 +24,7 @@ type SlackChannel struct {
type SlackUser struct {
Id string `json:"id"`
UserName string `json:"name"`
Username string `json:"name"`
Profile map[string]string `json:"profile"`
}
@@ -85,7 +85,6 @@ func SlackAddUsers(teamId string, slackusers []SlackUser, log *bytes.Buffer) map
log.WriteString("\n Users Created\n")
log.WriteString("===============\n\n")
// Add users
addedUsers := make(map[string]*model.User)
for _, sUser := range slackusers {
firstName := ""
@@ -101,7 +100,7 @@ func SlackAddUsers(teamId string, slackusers []SlackUser, log *bytes.Buffer) map
newUser := model.User{
TeamId: teamId,
Username: sUser.UserName,
Username: sUser.Username,
FirstName: firstName,
LastName: lastName,
Email: sUser.Profile["email"],
@@ -112,7 +111,7 @@ func SlackAddUsers(teamId string, slackusers []SlackUser, log *bytes.Buffer) map
addedUsers[sUser.Id] = mUser
log.WriteString("Email, Password: " + newUser.Email + ", " + password + "\n")
} else {
log.WriteString("Unable to import user: " + sUser.UserName)
log.WriteString("Unable to import user: " + sUser.Username)
}
}
@@ -167,7 +166,6 @@ func SlackAddChannels(teamId string, slackchannels []SlackChannel, posts map[str
log.WriteString("\n Channels Added \n")
log.WriteString("=================\n\n")
// Add channels
addedChannels := make(map[string]*model.Channel)
for _, sChannel := range slackchannels {
newChannel := model.Channel{

View File

@@ -494,8 +494,7 @@ func getMyTeam(c *Context, w http.ResponseWriter, r *http.Request) {
}
func importTeam(c *Context, w http.ResponseWriter, r *http.Request) {
if !c.HasPermissionsToTeam(c.Session.TeamId, "import") {
if !c.HasPermissionsToTeam(c.Session.TeamId, "import") || !c.IsTeamAdmin(c.Session.UserId) {
c.Err = model.NewAppError("importTeam", "Only a team admin can import data.", "userId="+c.Session.UserId)
c.Err.StatusCode = http.StatusForbidden
return

View File

@@ -1,4 +1,3 @@
// Copyright (c) 2015 Spinpunch, Inc. All Rights Reserved.
// See License.txt for license information.
var BrowserStore = require('../stores/browser_store.jsx');
@@ -859,7 +858,7 @@ module.exports.uploadProfileImage = function(imageData, success, error) {
module.exports.importSlack = function(fileData, success, error) {
$.ajax({
url: '/api/v1/teams/import_team',
url: '/api/v1/teams/import_team',
type: 'POST',
data: fileData,
cache: false,