auto update custom user access token
This commit is contained in:
parent
ab6dcf4313
commit
98791fb757
|
@ -4,6 +4,7 @@ import (
|
||||||
"crypto/hmac"
|
"crypto/hmac"
|
||||||
"crypto/sha512"
|
"crypto/sha512"
|
||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
|
@ -100,8 +101,13 @@ func (puppet *Puppet) StartCustomMXID() error {
|
||||||
}
|
}
|
||||||
resp, err := intent.Whoami()
|
resp, err := intent.Whoami()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
puppet.clearCustomMXID()
|
if strings.Index(err.Error(), "M_UNKNOWN_TOKEN (HTTP 401)") > -1 {
|
||||||
return err
|
err, _ = puppet.customUser.UpdateAccessToken(puppet)
|
||||||
|
}
|
||||||
|
if err != nil {
|
||||||
|
puppet.clearCustomMXID()
|
||||||
|
return err
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if resp.UserID != puppet.CustomMXID {
|
if resp.UserID != puppet.CustomMXID {
|
||||||
puppet.clearCustomMXID()
|
puppet.clearCustomMXID()
|
||||||
|
|
Loading…
Reference in New Issue