@@ -21,7 +21,10 @@ func (m *Manager) CreateSession(username, ipAddress, userAgent string) (uuid.UUI
21
21
22
22
/* check if session exists -> if yes, reset the timer and return the session ID */
23
23
if session , exists := m .sessionsMap [username ]; exists {
24
- m .RefreshTimer (username )
24
+ if err := m .RefreshTimer (username ); err != nil {
25
+ m .errCh <- err
26
+ return uuid .Nil , fmt .Errorf ("sessions exists, but failed to refresh the timer" )
27
+ }
25
28
return session .ID , nil
26
29
}
27
30
@@ -60,7 +63,10 @@ func (m *Manager) CreateSession(username, ipAddress, userAgent string) (uuid.UUI
60
63
m .sessionsMap [username ] = session
61
64
62
65
/* store session to Redis */
63
- m .saveSessionRedis (session )
66
+ if err := m .saveSessionRedis (session ); err != nil {
67
+ m .errCh <- err
68
+ return uuid .Nil , fmt .Errorf ("failed to store session to Redis" )
69
+ }
64
70
65
71
return sessionID , nil
66
72
}
@@ -238,11 +244,18 @@ func (m *Manager) RefreshTimer(username string) error {
238
244
239
245
/* reset the session timer */
240
246
session .Timer = time .AfterFunc (time .Duration (config .BackendConfig .AppInfo .SessionTimeout )* time .Hour ,
241
- func () { m .ExpireSession (username ) },
247
+ func () {
248
+ if err := m .ExpireSession (username ); err != nil {
249
+ m .errCh <- err
250
+ }
251
+ },
242
252
)
243
253
244
254
/* update Redis for session */
245
- m .saveSessionRedis (session )
255
+ if err := m .saveSessionRedis (session ); err != nil {
256
+ m .errCh <- err
257
+ return fmt .Errorf ("failed to store session to Redis" )
258
+ }
246
259
247
260
return nil
248
261
}
0 commit comments