Skip to content

Commit 5b053c8

Browse files
committed
fix(login): User should login by default when he registers
1 parent fb5e41c commit 5b053c8

5 files changed

Lines changed: 13 additions & 12 deletions

File tree

cmd/auth.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import (
1414

1515
// Register creates a account on a Deis controller.
1616
func (d *DeisCmd) Register(controller string, username string, password string, email string,
17-
sslVerify bool) error {
17+
sslVerify, login bool) error {
1818

1919
c, err := deis.New(sslVerify, controller, "")
2020

@@ -72,6 +72,10 @@ func (d *DeisCmd) Register(controller string, username string, password string,
7272

7373
d.Printf("Registered %s\n", username)
7474

75+
if login {
76+
return d.Login(controller, username, password, sslVerify)
77+
}
78+
7579
return nil
7680
}
7781

cmd/auth_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ func TestRegister(t *testing.T) {
5151
fmt.Fprintf(w, `{}`)
5252
})
5353

54-
err = cmdr.Register(server.Server.URL, username, password, email, true)
54+
err = cmdr.Register(server.Server.URL, username, password, email, true, false)
5555
assert.NoErr(t, err)
5656
expected := fmt.Sprintf("Registered %s\n", username)
5757

cmd/cmd.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ type Commander interface {
2121
AutoscaleList(string) error
2222
AutoscaleSet(string, string, int, int, int) error
2323
AutoscaleUnset(string, string) error
24-
Register(string, string, string, string, bool) error
24+
Register(string, string, string, string, bool, bool) error
2525
Login(string, string, string, bool) error
2626
Logout() error
2727
Passwd(string, string, string) error

parser/auth.go

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -81,24 +81,21 @@ Options:
8181
password := safeGetValue(args, "--password")
8282
email := safeGetValue(args, "--email")
8383
sslVerify := true
84+
login := true
8485

8586
if args["--ssl-verify"] != nil && args["--ssl-verify"].(string) == "false" {
8687
sslVerify = false
8788
}
8889

89-
if err := cmdr.Register(controller, username, password, email, sslVerify); err != nil {
90-
return err
91-
}
92-
9390
// NOTE(bacongobbler): two use cases to check here:
9491
//
9592
// 1) Legacy; calling `deis auth:register` without --login
96-
// 2) calling `deis auth:register --login true`
97-
if args["--login"] == nil || args["--login"].(string) == "true" {
98-
return cmdr.Login(controller, username, password, sslVerify)
93+
// 2) calling `deis auth:register --login false`
94+
if args["--login"] != nil && args["--login"].(string) == "false" {
95+
login = false
9996
}
10097

101-
return nil
98+
return cmdr.Register(controller, username, password, email, sslVerify, login)
10299
}
103100

104101
func authLogin(argv []string, cmdr cmd.Commander) error {

parser/auth_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import (
1212
// Create fake implementations of each method that return the argument
1313
// we expect to have called the function (as an error to satisfy the interface).
1414

15-
func (d FakeDeisCmd) Register(string, string, string, string, bool) error {
15+
func (d FakeDeisCmd) Register(string, string, string, string, bool, bool) error {
1616
return errors.New("auth:register")
1717
}
1818

0 commit comments

Comments
 (0)