-
Notifications
You must be signed in to change notification settings - Fork 1
/
logout.go
42 lines (34 loc) · 840 Bytes
/
logout.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
package conducts
import (
"context"
"time"
"github.com/pkg/errors"
"github.com/wolftotem4/shaolin-ben-don/internal/action"
"github.com/wolftotem4/shaolin-ben-don/internal/app"
)
func Logout(ctx context.Context, app *app.App) error {
ctx, cancel := context.WithTimeout(ctx, 30*time.Second)
defer cancel()
var (
interfaceValue int
)
// Refresh session status
{
// Refresh session status by loading the main page
act := &action.DashboardAction{Client: app.Client}
data, err := act.Update(ctx)
if err != nil {
return errors.WithStack(err)
}
// Get the interface value from the page
interfaceValue = data.Interface
}
// Perform loggout
{
act := &action.LogoutAction{Client: app.Client}
if err := act.ForceLogout(ctx, interfaceValue); err != nil {
return errors.WithStack(err)
}
}
return nil
}