Skip to content

Commit

Permalink
Merge pull request #23 from arvancloud/fix-wrong-api-key
Browse files Browse the repository at this point in the history
Add api check to fix wrong api key
  • Loading branch information
pjfa authored Jan 4, 2023
2 parents 5fab397 + be7494f commit 1a3ad1b
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions pkg/paas/login.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,22 @@ func NewCmdLogin(in io.Reader, out, errout io.Writer) *cobra.Command {

arvanConfig := config.GetConfigInfo()

tempApiKey := arvanConfig.GetApiKey()

arvanConfig.Initiate(apiKey, *region)

utl.CheckErr(arvanConfig.Complete())

_, err = arvanConfig.SaveConfig()
utl.CheckErr(err)

_, err = isAuthorized(apiKey)
utl.CheckErr(err)
isAuthorized, authErr := isAuthorized(apiKey)
if !isAuthorized {
arvanConfig.Initiate(tempApiKey, *region)
_, err = arvanConfig.SaveConfig()
utl.CheckErr(err)
}
utl.CheckErr(authErr)

if c != nil {
err = prepareConfig(c)
Expand Down

0 comments on commit 1a3ad1b

Please sign in to comment.