mirror of
https://github.com/juanfont/headscale.git
synced 2024-11-26 08:53:05 +00:00
Fix OIDCCallbackHandler
This commit is contained in:
parent
38533c99aa
commit
6997becdd3
1 changed files with 9 additions and 7 deletions
|
@ -254,7 +254,8 @@ func (a *AuthProviderOIDC) OIDCCallbackHandler(
|
|||
|
||||
// Register the node if it does not exist.
|
||||
if mKey != nil {
|
||||
if err := a.registerNode(user, mKey, nodeExpiry); err != nil {
|
||||
node, err = a.registerNode(user, mKey, nodeExpiry)
|
||||
if err != nil {
|
||||
http.Error(writer, err.Error(), http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
|
@ -448,21 +449,22 @@ func (a *AuthProviderOIDC) registerNode(
|
|||
user *types.User,
|
||||
machineKey *key.MachinePublic,
|
||||
expiry time.Time,
|
||||
) error {
|
||||
) (*types.Node, error) {
|
||||
ipv4, ipv6, err := a.ipAlloc.Next()
|
||||
if err != nil {
|
||||
return err
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if _, err := a.db.RegisterNodeFromAuthCallback(
|
||||
node, err := a.db.RegisterNodeFromAuthCallback(
|
||||
*machineKey,
|
||||
types.UserID(user.ID),
|
||||
&expiry,
|
||||
util.RegisterMethodOIDC,
|
||||
ipv4, ipv6,
|
||||
); err != nil {
|
||||
return fmt.Errorf("could not register node: %w", err)
|
||||
)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("could not register node: %w", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
return node, nil
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue