///////////////////////////////////////////////
// Create user directories, for code files and resources
func (c *SignupController) createUserDirectory(user models.User, group string) {

	// Create project directories
	models.CreateDirectories(beego.AppConfig.String("userdata::location")+user.Name, true)

	// Create .spielplatz files
	dir := beego.AppConfig.String("userdata::location") + user.Name + "/" + beego.AppConfig.String("userdata::spielplatzdir") + "/"
	identityFile := dir + "identity"
	file, err := os.Create(identityFile)
	if err != nil {
		beego.Error(err)
	}
	file.Close()
	cnf, err := config.NewConfig("ini", identityFile)
	if err != nil {
		beego.Error("Cannot create identity file in " + dir + " (" + err.Error() + ")")
	}
	cnf.Set("auth::Pwhash", user.Pwhash)
	cnf.Set("rights::NoSpecialRights", "true")
	cnf.Set("groups::member", group)
	cnf.SaveConfigFile(identityFile)

	// Clone Admin Spielplatz project
	err = models.CloneProjectDir(user.Name, beego.AppConfig.String("userdata::commonproject"), true)
	if err != nil {
		beego.Error(err)
	}
}
func cloneProject(s session.Store, projectName string) Data {

	// if user is not logged in return
	userName := ""
	if s.Get("UserName") != nil {
		userName = s.Get("UserName").(string)
	}
	if userName == "" {
		beego.Error("No user name available.")
		return Data{}
	}
	beego.Warning("Entering cloneProject with", userName, "and", projectName)
	if projectName == "" {
		beego.Error("No project name available.")
		return Data{}
	}

	// Check for rights
	// Maybe add a token check here, otherwise manipulated clients can clone any project

	models.CloneProjectDir(userName, projectName, false)
	return Data{
		"ProjectName": projectName,
	}
}