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