From 5efe2504669c13dbf90be998615a3b65e516245f Mon Sep 17 00:00:00 2001 From: Manfred Touron Date: Tue, 2 Jan 2018 23:20:03 +0100 Subject: [PATCH] hotfix: repair invite system (broken in v1.7.0) --- CHANGELOG.md | 1 + ssh.go | 8 ++++---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8d8631d..a64d302 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ ## master (unreleased) * Return non-null exit-code on authentication error +* **hotfix**: repair invite system (broken in v1.7.0) ## v1.7.0 (2018-01-02) diff --git a/ssh.go b/ssh.go index 04d4409..eadeae0 100644 --- a/ssh.go +++ b/ssh.go @@ -249,14 +249,14 @@ func publicKeyAuthHandler(db *gorm.DB, globalContext *cli.Context) ssh.PublicKey db.Where("authorized_key = ?", string(gossh.MarshalAuthorizedKey(key))).First(&actx.userKey) if actx.userKey.UserID > 0 { db.Preload("Roles").Where("id = ?", actx.userKey.UserID).First(&actx.user) - if actx.userType() == "invite" { + if actx.userType() == UserTypeInvite { actx.err = fmt.Errorf("invites are only supported for new SSH keys; your ssh key is already associated with the user %q", actx.user.Email) } return true } // handle invite "links" - if actx.userType() == "invite" { + if actx.userType() == UserTypeInvite { inputToken := strings.Split(actx.inputUsername, ":")[1] if len(inputToken) > 0 { db.Where("invite_token = ?", inputToken).First(&actx.user) @@ -268,11 +268,11 @@ func publicKeyAuthHandler(db *gorm.DB, globalContext *cli.Context) ssh.PublicKey Comment: "created by sshportal", AuthorizedKey: string(gossh.MarshalAuthorizedKey(key)), } - db.Create(actx.userKey) + db.Create(&actx.userKey) // token is only usable once actx.user.InviteToken = "" - db.Model(actx.user).Updates(actx.user) + db.Model(&actx.user).Updates(&actx.user) actx.message = fmt.Sprintf("Welcome %s!\n\nYour key is now associated with the user %q.\n", actx.user.Name, actx.user.Email) } else {