Mercurial > gemma
comparison pkg/controllers/pwreset.go @ 1327:cabf4789e02b
To make golint happier made context.Context to be the first argument of auth.RunAs.
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Sun, 25 Nov 2018 15:56:07 +0100 |
parents | 5443f5c9154c |
children | ed4820efb7e6 |
comparison
equal
deleted
inserted
replaced
1326:515815565bd0 | 1327:cabf4789e02b |
---|---|
120 | 120 |
121 func removeOutdated() { | 121 func removeOutdated() { |
122 config.WaitReady() | 122 config.WaitReady() |
123 for { | 123 for { |
124 time.Sleep(cleanupPause) | 124 time.Sleep(cleanupPause) |
125 ctx := context.Background() | |
125 err := auth.RunAs( | 126 err := auth.RunAs( |
126 pwResetRole, context.Background(), | 127 ctx, pwResetRole, |
127 func(conn *sql.Conn) error { | 128 func(conn *sql.Conn) error { |
128 good := time.Now().Add(-passwordResetValid) | 129 good := time.Now().Add(-passwordResetValid) |
129 _, err := conn.ExecContext( | 130 _, err := conn.ExecContext( |
130 context.Background(), cleanupRequestsSQL, good) | 131 ctx, cleanupRequestsSQL, good) |
131 return err | 132 return err |
132 }) | 133 }) |
133 if err != nil { | 134 if err != nil { |
134 log.Printf("error: %v\n", err) | 135 log.Printf("error: %v\n", err) |
135 } | 136 } |
206 var hash, email string | 207 var hash, email string |
207 | 208 |
208 ctx := context.Background() | 209 ctx := context.Background() |
209 | 210 |
210 if err := auth.RunAs( | 211 if err := auth.RunAs( |
211 pwResetRole, ctx, | 212 ctx, pwResetRole, |
212 func(conn *sql.Conn) error { | 213 func(conn *sql.Conn) error { |
213 | 214 |
214 var count int64 | 215 var count int64 |
215 if err := conn.QueryRowContext( | 216 if err := conn.QueryRowContext( |
216 ctx, countRequestsSQL).Scan(&count); err != nil { | 217 ctx, countRequestsSQL).Scan(&count); err != nil { |
302 var email, user, password string | 303 var email, user, password string |
303 | 304 |
304 ctx := req.Context() | 305 ctx := req.Context() |
305 | 306 |
306 if err = auth.RunAs( | 307 if err = auth.RunAs( |
307 pwResetRole, ctx, func(conn *sql.Conn) error { | 308 ctx, pwResetRole, func(conn *sql.Conn) error { |
308 err := conn.QueryRowContext(ctx, findRequestSQL, hash).Scan(&email, &user) | 309 err := conn.QueryRowContext(ctx, findRequestSQL, hash).Scan(&email, &user) |
309 switch { | 310 switch { |
310 case err == sql.ErrNoRows: | 311 case err == sql.ErrNoRows: |
311 return JSONError{http.StatusNotFound, "No such hash"} | 312 return JSONError{http.StatusNotFound, "No such hash"} |
312 case err != nil: | 313 case err != nil: |