mirror of
https://github.com/netbirdio/netbird.git
synced 2025-06-20 01:38:41 +02:00
Reject peer login expiration update when no SSO login (#693)
This commit is contained in:
parent
fe63a64b6e
commit
44af5be30f
@ -69,6 +69,11 @@ type Peer struct {
|
|||||||
LastLogin time.Time
|
LastLogin time.Time
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// AddedWithSSOLogin indicates whether this peer has been added with an SSO login by a user.
|
||||||
|
func (p *Peer) AddedWithSSOLogin() bool {
|
||||||
|
return p.UserID != ""
|
||||||
|
}
|
||||||
|
|
||||||
// Copy copies Peer object
|
// Copy copies Peer object
|
||||||
func (p *Peer) Copy() *Peer {
|
func (p *Peer) Copy() *Peer {
|
||||||
return &Peer{
|
return &Peer{
|
||||||
@ -290,6 +295,11 @@ func (am *DefaultAccountManager) UpdatePeer(accountID, userID string, update *Pe
|
|||||||
}
|
}
|
||||||
|
|
||||||
if peer.LoginExpirationEnabled != update.LoginExpirationEnabled {
|
if peer.LoginExpirationEnabled != update.LoginExpirationEnabled {
|
||||||
|
|
||||||
|
if !peer.AddedWithSSOLogin() {
|
||||||
|
return nil, status.Errorf(status.PreconditionFailed, "this peer hasn't been added with the SSO login, therefore the login expiration can't be updated")
|
||||||
|
}
|
||||||
|
|
||||||
peer.LoginExpirationEnabled = update.LoginExpirationEnabled
|
peer.LoginExpirationEnabled = update.LoginExpirationEnabled
|
||||||
|
|
||||||
event := activity.PeerLoginExpirationEnabled
|
event := activity.PeerLoginExpirationEnabled
|
||||||
|
Loading…
x
Reference in New Issue
Block a user