diff --git a/pkg/database/members.go b/pkg/database/members.go index c6d6ebff3..d621f1508 100644 --- a/pkg/database/members.go +++ b/pkg/database/members.go @@ -33,7 +33,7 @@ WHERE user_id = ? AND team_id = ? // SQL Queries to retrieve a member's role by id and user. const roleFindStmt = ` -SELECT role FROM members +SELECT id, team_id, user_id, role FROM members WHERE user_id = ? AND team_id = ? ` diff --git a/pkg/handler/admin.go b/pkg/handler/admin.go index d7840c7fb..ff21090f3 100644 --- a/pkg/handler/admin.go +++ b/pkg/handler/admin.go @@ -179,6 +179,11 @@ func AdminSettingsUpdate(w http.ResponseWriter, r *http.Request, u *User) error settings.OpenInvitations = (r.FormValue("OpenInvitations") == "on") + // validate user input + if err := settings.Validate(); err != nil { + return RenderError(w, err, http.StatusBadRequest) + } + // persist changes if err := database.SaveSettings(settings); err != nil { return RenderError(w, err, http.StatusBadRequest) @@ -245,8 +250,8 @@ func InstallPost(w http.ResponseWriter, r *http.Request) error { settings := Settings{} settings.Domain = r.FormValue("Domain") settings.Scheme = r.FormValue("Scheme") - settings.GitHubApiUrl = "https://api.github.com"; - settings.GitHubDomain = "github.com"; + settings.GitHubApiUrl = "https://api.github.com" + settings.GitHubDomain = "github.com" database.SaveSettings(&settings) // add the user to the session object diff --git a/pkg/handler/auth.go b/pkg/handler/auth.go index 7e91787ee..77166b55a 100644 --- a/pkg/handler/auth.go +++ b/pkg/handler/auth.go @@ -1,6 +1,7 @@ package handler import ( + "log" "net/http" "github.com/drone/drone/pkg/database" @@ -67,6 +68,7 @@ func LinkGithub(w http.ResponseWriter, r *http.Request, u *User) error { // exchange code for an auth token token, err := oauth.GrantToken(code) if err != nil { + log.Println("Error granting GitHub authorization token") return err } @@ -77,6 +79,7 @@ func LinkGithub(w http.ResponseWriter, r *http.Request, u *User) error { // get the user information githubUser, err := client.Users.Current() if err != nil { + log.Println("Error retrieving currently authenticated GitHub user") return err } @@ -84,6 +87,7 @@ func LinkGithub(w http.ResponseWriter, r *http.Request, u *User) error { u.GithubToken = token.AccessToken u.GithubLogin = githubUser.Login if err := database.SaveUser(u); err != nil { + log.Println("Error persisting user's GitHub auth token to the database") return err }