mirror of
https://github.com/getAlby/hub.git
synced 2026-08-13 12:33:39 +02:00
fix: delete access token when creating backup to migrate node (#1040)
This commit is contained in:
parent
a23e24ddd9
commit
82e4a162fb
3 changed files with 17 additions and 0 deletions
|
|
@ -88,6 +88,14 @@ func NewAlbyOAuthService(db *gorm.DB, cfg config.Config, keys keys.Keys, eventPu
|
|||
return albyOAuthSvc
|
||||
}
|
||||
|
||||
func (svc *albyOAuthService) RemoveOAuthAccessToken() error {
|
||||
err := svc.cfg.SetUpdate(accessTokenKey, "", "")
|
||||
if err != nil {
|
||||
logger.Logger.WithError(err).Error("failed to remove access token")
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
func (svc *albyOAuthService) CallbackHandler(ctx context.Context, code string, lnClient lnclient.LNClient) error {
|
||||
token, err := svc.oauthConf.Exchange(ctx, code)
|
||||
if err != nil {
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@ type AlbyOAuthService interface {
|
|||
UnlinkAccount(ctx context.Context) error
|
||||
RequestAutoChannel(ctx context.Context, lnClient lnclient.LNClient, isPublic bool) (*AutoChannelResponse, error)
|
||||
GetVssAuthToken(ctx context.Context, nodeIdentifier string) (string, error)
|
||||
RemoveOAuthAccessToken() error
|
||||
}
|
||||
|
||||
type AlbyBalanceResponse struct {
|
||||
|
|
|
|||
|
|
@ -67,6 +67,14 @@ func (api *api) CreateBackup(unlockPassword string, w io.Writer) error {
|
|||
// Stop the app to ensure no new requests are processed.
|
||||
api.svc.StopApp()
|
||||
|
||||
// Remove the OAuth access token from the DB to ensure the user
|
||||
// has to re-auth with the correct OAuth client when they restore the backup
|
||||
err = api.albyOAuthSvc.RemoveOAuthAccessToken()
|
||||
if err != nil {
|
||||
logger.Logger.WithError(err).Error("Failed to remove oauth access token")
|
||||
return errors.New("failed to remove oauth access token")
|
||||
}
|
||||
|
||||
// Closing the database leaves the service in an inconsistent state,
|
||||
// but that should not be a problem since the app is not expected
|
||||
// to be used after its data is exported.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue