Last small fixes for 0.8
This commit is contained in:
+5
-33
@@ -867,12 +867,6 @@ func deleteUser(resp http.ResponseWriter, request *http.Request) {
|
||||
userId = location[4]
|
||||
}
|
||||
|
||||
if userId == userInfo.Id {
|
||||
resp.WriteHeader(401)
|
||||
resp.Write([]byte(`{"success": false, "reason": "Can't deactivate yourself"}`))
|
||||
return
|
||||
}
|
||||
|
||||
ctx := context.Background()
|
||||
foundUser, err := getUser(ctx, userId)
|
||||
if err != nil {
|
||||
@@ -904,6 +898,7 @@ func deleteUser(resp http.ResponseWriter, request *http.Request) {
|
||||
|
||||
// Invert. No user deletion.
|
||||
if foundUser.Active {
|
||||
|
||||
foundUser.Active = false
|
||||
} else {
|
||||
foundUser.Active = true
|
||||
@@ -1180,6 +1175,7 @@ func createNewUser(username, password, role, apikey string, org Org) error {
|
||||
ID := uuid.NewV4()
|
||||
newUser.Id = ID.String()
|
||||
newUser.VerificationToken = verifyToken.String()
|
||||
|
||||
err = setUser(ctx, newUser)
|
||||
if err != nil {
|
||||
log.Printf("Error adding User %s: %s", username, err)
|
||||
@@ -1187,10 +1183,8 @@ func createNewUser(username, password, role, apikey string, org Org) error {
|
||||
}
|
||||
|
||||
neworg, err := getOrg(ctx, org.Id)
|
||||
log.Printf("Users: %d", len(org.Users))
|
||||
if err == nil {
|
||||
log.Printf("Updating org %s with user %s", org.Name, newUser.Username)
|
||||
neworg.Users = append(org.Users, *newUser)
|
||||
neworg.Users = append(neworg.Users, *newUser)
|
||||
err = setOrg(ctx, *neworg, neworg.Id)
|
||||
if err != nil {
|
||||
log.Printf("Failed updating org with user %s", newUser.Username)
|
||||
@@ -1199,26 +1193,6 @@ func createNewUser(username, password, role, apikey string, org Org) error {
|
||||
}
|
||||
}
|
||||
|
||||
// url := fmt.Sprintf("https://shuffler.io/register/%s", verifyToken.String())
|
||||
// const verifyMessage = `
|
||||
//Registration URL :)
|
||||
//
|
||||
//%s
|
||||
// `
|
||||
// addr := newUser.Username
|
||||
//
|
||||
// msg := &mail.Message{
|
||||
// Sender: "Shuffle <frikky@shuffler.io>",
|
||||
// To: []string{addr},
|
||||
// Subject: "Verify your username - Shuffle",
|
||||
// Body: fmt.Sprintf(verifyMessage, url),
|
||||
// }
|
||||
//
|
||||
// log.Println(msg.Body)
|
||||
// if err := mail.Send(ctx, msg); err != nil {
|
||||
// log.Printf("Couldn't send email: %v", err)
|
||||
// }
|
||||
|
||||
err = increaseStatisticsField(ctx, "successful_register", username, 1)
|
||||
if err != nil {
|
||||
log.Printf("Failed to increase total apps loaded stats: %s", err)
|
||||
@@ -2462,6 +2436,7 @@ func handleGetUsers(resp http.ResponseWriter, request *http.Request) {
|
||||
item.Password = ""
|
||||
item.Session = ""
|
||||
item.VerificationToken = ""
|
||||
item.Orgs = []string{}
|
||||
|
||||
newUsers = append(newUsers, item)
|
||||
}
|
||||
@@ -2808,7 +2783,6 @@ func fixUserOrg(ctx context.Context, user *User) *User {
|
||||
user.Orgs = append(user.Orgs, user.ActiveOrg.Id)
|
||||
}
|
||||
|
||||
log.Printf("Updating %d orgs for user %s", len(user.Orgs), user.Id)
|
||||
// Might be vulnerable to timing attacks.
|
||||
for _, orgId := range user.Orgs {
|
||||
if len(orgId) == 0 {
|
||||
@@ -2821,8 +2795,6 @@ func fixUserOrg(ctx context.Context, user *User) *User {
|
||||
continue
|
||||
}
|
||||
|
||||
log.Printf("Org users: %d", len(org.Users))
|
||||
|
||||
orgIndex := 0
|
||||
userFound := false
|
||||
for index, orgUser := range org.Users {
|
||||
@@ -2844,7 +2816,6 @@ func fixUserOrg(ctx context.Context, user *User) *User {
|
||||
org.Users = append(org.Users, *user)
|
||||
}
|
||||
|
||||
log.Printf("Users 2: %d", len(org.Users))
|
||||
err = setOrg(ctx, *org, orgId)
|
||||
if err != nil {
|
||||
log.Printf("Failed setting org %s", orgId)
|
||||
@@ -7719,6 +7690,7 @@ func handleEditOrg(resp http.ResponseWriter, request *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
log.Printf("SUCCESSFULLY UPDATED ORG")
|
||||
resp.WriteHeader(200)
|
||||
resp.Write([]byte(fmt.Sprintf(`{"success": true, "reason": "Successfully updated org"}`)))
|
||||
|
||||
|
||||
@@ -73,6 +73,8 @@ type SyncFeatures struct {
|
||||
UserInput SyncData `json:"user_input" datastore:"user_input"`
|
||||
SendMail SyncData `json:"send_mail" datastore:"send_mail"`
|
||||
SendSms SyncData `json:"send_sms" datastore:"send_sms"`
|
||||
Updates SyncData `json:"updates" datastore:"updates"`
|
||||
Notifications SyncData `json:"notifications" datastore:"notifications"`
|
||||
EmailTrigger SyncData `json:"email_trigger" datastore:"email_trigger"`
|
||||
AppExecutions SyncData `json:"app_executions" datastore:"app_executions"`
|
||||
WorkflowExecutions SyncData `json:"workflow_executions" datastore:"workflow_executions"`
|
||||
@@ -84,13 +86,14 @@ type SyncFeatures struct {
|
||||
}
|
||||
|
||||
type SyncData struct {
|
||||
Active bool `json:"active" datastore:"active"`
|
||||
Type string `json:"type" datastore:"type"`
|
||||
Name string `json:"name" datastore:"name"`
|
||||
Description string `json:"description" datastore:"description"`
|
||||
Limit int64 `json:"limit" datastore:"limit"`
|
||||
StartDate int64 `json:"start_date" datastore:"start_date"`
|
||||
EndDate int64 `json:"end_date" datastore:"end_date"`
|
||||
Active bool `json:"active" datastore:"active"`
|
||||
Type string `json:"type" datastore:"type"`
|
||||
Name string `json:"name" datastore:"name"`
|
||||
Description string `json:"description" datastore:"description"`
|
||||
Limit int64 `json:"limit" datastore:"limit"`
|
||||
StartDate int64 `json:"start_date" datastore:"start_date"`
|
||||
EndDate int64 `json:"end_date" datastore:"end_date"`
|
||||
DataCollection int64 `json:"data_collection" datastore:"data_collection"`
|
||||
}
|
||||
|
||||
type SyncConfig struct {
|
||||
@@ -1193,7 +1196,7 @@ func handleWorkflowQueue(resp http.ResponseWriter, request *http.Request) {
|
||||
|
||||
// Handles extra statistics stuff when it's done
|
||||
// Does autocomplete magic with JSON
|
||||
go handleExecutionStatistics(*workflowExecution)
|
||||
handleExecutionStatistics(*workflowExecution)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+78
-205
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -22,8 +22,9 @@ const Body = {
|
||||
const dividerColor = "rgb(225, 228, 232)"
|
||||
|
||||
const SideBar = {
|
||||
maxWidth: "250px",
|
||||
maxWidth: 250,
|
||||
flex: "1",
|
||||
position: "fixed",
|
||||
}
|
||||
|
||||
const hrefStyle = {
|
||||
@@ -165,6 +166,7 @@ const Docs = (props) => {
|
||||
maxWidth: 750,
|
||||
overflow: "hidden",
|
||||
paddingBottom: 200,
|
||||
marginLeft: 250,
|
||||
}
|
||||
|
||||
function OuterLink(props) {
|
||||
@@ -212,11 +214,11 @@ const Docs = (props) => {
|
||||
<div style={Body}>
|
||||
<div style={SideBar}>
|
||||
<ul style={{listStyle: "none", paddingLeft: "0"}}>
|
||||
{list.map(item => {
|
||||
{list.map((item, index) => {
|
||||
const path = "/docs/"+item
|
||||
const newname = item.charAt(0).toUpperCase()+item.substring(1).split("_").join(" ").split("-").join(" ")
|
||||
return (
|
||||
<li style={{marginTop: "10px"}}>
|
||||
<li key={index} style={{marginTop: "10px"}}>
|
||||
<Link style={hrefStyle} to={path} onClick={() => {fetchDocs(item)}}>
|
||||
<h2>{newname}</h2>
|
||||
</Link>
|
||||
|
||||
Reference in New Issue
Block a user