|
|
@ -4,6 +4,7 @@
|
|
|
|
package cmd
|
|
|
|
package cmd
|
|
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
import (
|
|
|
|
|
|
|
|
"errors"
|
|
|
|
"fmt"
|
|
|
|
"fmt"
|
|
|
|
|
|
|
|
|
|
|
|
auth_model "code.gitea.io/gitea/models/auth"
|
|
|
|
auth_model "code.gitea.io/gitea/models/auth"
|
|
|
@ -42,7 +43,7 @@ var microcmdUserGenerateAccessToken = &cli.Command{
|
|
|
|
|
|
|
|
|
|
|
|
func runGenerateAccessToken(c *cli.Context) error {
|
|
|
|
func runGenerateAccessToken(c *cli.Context) error {
|
|
|
|
if !c.IsSet("username") {
|
|
|
|
if !c.IsSet("username") {
|
|
|
|
return fmt.Errorf("You must provide a username to generate a token for")
|
|
|
|
return errors.New("You must provide a username to generate a token for")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
ctx, cancel := installSignals()
|
|
|
|
ctx, cancel := installSignals()
|
|
|
@ -68,7 +69,7 @@ func runGenerateAccessToken(c *cli.Context) error {
|
|
|
|
return err
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if exist {
|
|
|
|
if exist {
|
|
|
|
return fmt.Errorf("access token name has been used already")
|
|
|
|
return errors.New("access token name has been used already")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// make sure the scopes are valid
|
|
|
|
// make sure the scopes are valid
|
|
|
|