fixes nil ref in tests

This commit is contained in:
bergquist 2019-01-22 16:16:32 +01:00
parent 31b5db06f1
commit c3ff3d644c
3 changed files with 15 additions and 8 deletions

View File

@ -47,13 +47,13 @@ func (hs *HTTPServer) LoginView(c *m.ReqContext) {
return return
//} //}
if redirectTo, _ := url.QueryUnescape(c.GetCookie("redirect_to")); len(redirectTo) > 0 { // if redirectTo, _ := url.QueryUnescape(c.GetCookie("redirect_to")); len(redirectTo) > 0 {
c.SetCookie("redirect_to", "", -1, setting.AppSubUrl+"/") // c.SetCookie("redirect_to", "", -1, setting.AppSubUrl+"/")
c.Redirect(redirectTo) // c.Redirect(redirectTo)
return // return
} // }
c.Redirect(setting.AppSubUrl + "/") // c.Redirect(setting.AppSubUrl + "/")
} }
func tryOAuthAutoLogin(c *m.ReqContext) bool { func tryOAuthAutoLogin(c *m.ReqContext) bool {

View File

@ -66,7 +66,7 @@ func initContextWithAuthProxy(ctx *m.ReqContext, orgID int64) bool {
query.UserId = getRequestUserId(ctx) query.UserId = getRequestUserId(ctx)
// if we're using ldap, pass authproxy login name to ldap user sync // if we're using ldap, pass authproxy login name to ldap user sync
} else if setting.LdapEnabled { } else if setting.LdapEnabled {
ctx.Session.Delete(session.SESS_KEY_LASTLDAPSYNC) ctx.Session.Delete(session.SESS_KEY_LASTLDAPSYNC) //makes sure we always sync with ldap if session if we only have last sync info in session but not user.
syncQuery := &m.LoginUserQuery{ syncQuery := &m.LoginUserQuery{
ReqContext: ctx, ReqContext: ctx,

View File

@ -291,6 +291,13 @@ func createTestContext(t *testing.T) *testContext {
sqlstore := sqlstore.InitTestDB(t) sqlstore := sqlstore.InitTestDB(t)
tokenService := &UserAuthTokenServiceImpl{ tokenService := &UserAuthTokenServiceImpl{
SQLStore: sqlstore, SQLStore: sqlstore,
Cfg: &setting.Cfg{
LoginCookieName: "grafana_session",
LoginCookieUsername: "grafana_username",
LoginCookieSecure: false,
LoginCookieMaxDays: 7,
LoginDeleteExpiredTokensAfterDays: 30,
},
log: log.New("test-logger"), log: log.New("test-logger"),
} }