mirror of
https://github.com/gravitl/netmaker.git
synced 2024-11-14 13:44:37 +08:00
31 lines
773 B
Go
31 lines
773 B
Go
package config
|
|
|
|
import (
|
|
"encoding/base64"
|
|
"encoding/json"
|
|
|
|
"github.com/gravitl/netmaker/logger"
|
|
"github.com/gravitl/netmaker/models"
|
|
)
|
|
|
|
var (
|
|
// GuiActive - indicates if gui is active or not
|
|
GuiActive = false
|
|
// GuiRun - holds function for main to call
|
|
GuiRun interface{}
|
|
)
|
|
|
|
// ParseAccessToken - used to parse the base64 encoded access token
|
|
func ParseAccessToken(token string) (*models.AccessToken, error) {
|
|
tokenbytes, err := base64.StdEncoding.DecodeString(token)
|
|
if err != nil {
|
|
logger.Log(0, "error decoding token", err.Error())
|
|
return nil, err
|
|
}
|
|
var accesstoken models.AccessToken
|
|
if err := json.Unmarshal(tokenbytes, &accesstoken); err != nil {
|
|
logger.Log(0, "error decoding token", err.Error())
|
|
return nil, err
|
|
}
|
|
return &accesstoken, nil
|
|
}
|