-
Notifications
You must be signed in to change notification settings - Fork 1
/
login.go
50 lines (40 loc) · 1.16 KB
/
login.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package loginhandler
import (
"context"
"net/url"
"github.com/flimzy/jqeventrouter"
"github.com/flimzy/log"
"github.com/gopherjs/gopherjs/js"
"github.com/gopherjs/jquery"
"github.com/FlashbackSRS/flashback/model"
)
var jQuery = jquery.NewJQuery
// BeforeTransition prepares the logout page before display.
func BeforeTransition(repo *model.Repo, providers map[string]string) jqeventrouter.HandlerFunc {
return func(_ *jquery.Event, ui *js.Object, _ url.Values) bool {
log.Debug("login BEFORE")
cancel := checkLoginStatus(repo)
container := jQuery(ui.Get("toPage"))
for rel, href := range providers {
setLoginHandler(repo, container, rel, href, cancel)
}
jQuery(".show-until-load", container).Hide()
jQuery(".hide-until-load", container).Show()
return true
}
}
func checkCtx(ctx context.Context) error {
select {
case <-ctx.Done():
return ctx.Err()
default:
return nil
}
}
func displayError(msg string) {
log.Printf("Authentication error: %s\n", msg)
container := jQuery(":mobile-pagecontainer")
jQuery("#auth_fail_reason", container).SetText(msg)
jQuery(".show-until-load", container).Hide()
jQuery(".hide-until-load", container).Show()
}