@@ -40,14 +40,26 @@ var (
40
40
// On successful authentication returns a valid user object.
41
41
// Returns nil if authentication fails.
42
42
type SSPI struct {
43
+ rnd * render.Render
43
44
}
44
45
45
46
// Init creates a new global websspi.Authenticator object
46
47
func (s * SSPI ) Init () error {
47
48
config := websspi .NewConfig ()
48
49
var err error
49
50
sspiAuth , err = websspi .New (config )
50
- return err
51
+ if err != nil {
52
+ return err
53
+ }
54
+ s .rnd = render .New (render.Options {
55
+ Extensions : []string {".tmpl" },
56
+ Directory : "templates" ,
57
+ Funcs : templates .NewFuncMap (),
58
+ Asset : templates .GetAsset ,
59
+ AssetNames : templates .GetAssetNames ,
60
+ IsDevelopment : setting .RunMode != "prod" ,
61
+ })
62
+ return nil
51
63
}
52
64
53
65
// Free releases resources used by the global websspi.Authenticator object
@@ -86,19 +98,10 @@ func (s *SSPI) VerifyAuthData(req *http.Request, w http.ResponseWriter, store Da
86
98
store .GetData ()["Flash" ] = map [string ]string {
87
99
"ErrMsg" : err .Error (),
88
100
}
89
-
90
101
store .GetData ()["EnableOpenIDSignIn" ] = setting .Service .EnableOpenIDSignIn
91
102
store .GetData ()["EnableSSPI" ] = true
92
103
93
- rnd := render .New (render.Options {
94
- Extensions : []string {".tmpl" },
95
- Directory : "templates" ,
96
- Funcs : templates .NewFuncMap (),
97
- Asset : templates .GetAsset ,
98
- AssetNames : templates .GetAssetNames ,
99
- IsDevelopment : setting .RunMode != "prod" ,
100
- })
101
- err := rnd .HTML (w , 401 , string (tplSignIn ), templates .BaseVars ().Merge (store .GetData ()))
104
+ err := s .rnd .HTML (w , 401 , string (tplSignIn ), templates .BaseVars ().Merge (store .GetData ()))
102
105
if err != nil {
103
106
log .Error ("%v" , err )
104
107
}
0 commit comments