Skip to content
This repository has been archived by the owner on Oct 11, 2021. It is now read-only.

Commit

Permalink
add user checker
Browse files Browse the repository at this point in the history
  • Loading branch information
abdfnx committed May 25, 2021
1 parent 2bec55d commit 155dc98
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 4 deletions.
2 changes: 1 addition & 1 deletion core/authflow/success.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const oauthSuccessPage = `
}
</style>
<body>
<img src="https://imgs-secman.web.app/logo.png" />
<img src="https://assets.secman.dev/logo.svg" />
<div class="box">
<h1>Successfully authenticated Secman With Github 🔗</h1>
<p>You may now close this tab and return to the terminal.</p>
Expand Down
2 changes: 1 addition & 1 deletion core/container/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ func mainRun() exitCode {

hasDebug := os.Getenv("DEBUG") != ""

cmdFactory := factory.New(buildVersion)
cmdFactory := factory.New()
stderr := cmdFactory.IOStreams.ErrOut
if !cmdFactory.IOStreams.ColorEnabled() {
surveyCore.DisableColor = true
Expand Down
4 changes: 2 additions & 2 deletions pkg/cmd/factory/default.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
"github.com/secman-team/gh-api/pkg/iostreams"
)

func New(appVersion string) *cmdutil.Factory {
func New() *cmdutil.Factory {
io := iostreams.System()

var cachedConfig config.Config
Expand Down Expand Up @@ -52,7 +52,7 @@ func New(appVersion string) *cmdutil.Factory {
return nil, err
}

return NewHTTPClient(io, cfg, appVersion, true), nil
return NewHTTPClient(io, cfg, "x", true), nil
},
BaseRepo: func() (ghrepo.Interface, error) {
remotes, err := remotesFunc()
Expand Down
26 changes: 26 additions & 0 deletions pkg/cmd/repo/repo.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package repo

import (
"os"
"fmt"
"github.com/MakeNowJust/heredoc"
repoCloneCmd "github.com/secman-team/gh-api/pkg/cmd/repo/clone"
repoCreateCmd "github.com/secman-team/gh-api/pkg/cmd/repo/create"
Expand All @@ -11,8 +13,25 @@ import (
repoViewCmd "github.com/secman-team/gh-api/pkg/cmd/repo/view"
"github.com/secman-team/gh-api/pkg/cmdutil"
"github.com/spf13/cobra"
"github.com/abdfnx/git_config"
"github.com/secman-team/gh-api/pkg/cmd/factory"
"github.com/secman-team/gh-api/pkg/iostreams"
)

type ColorScheme struct {
IO *iostreams.IOStreams
}

func opts(f *cmdutil.Factory) ColorScheme {
opts := ColorScheme{
IO: f.IOStreams,
}

return opts
}

var cs = opts(factory.New()).IO.ColorScheme()

func NewCmdRepo(f *cmdutil.Factory) *cobra.Command {
cmd := &cobra.Command{
Use: "repo <command>",
Expand All @@ -39,5 +58,12 @@ func NewCmdRepo(f *cmdutil.Factory) *cobra.Command {
cmd.AddCommand(creditsCmd.NewCmdRepoCredits(f, nil))
cmd.AddCommand(gardenCmd.NewCmdGarden(f, nil))

username := git_config.GitConfig()
if username == ":username" {
fmt.Println("You're not authenticated, to authenticate run " + cs.Bold("secman auth login"))

os.Exit(0)
}

return cmd
}

0 comments on commit 155dc98

Please sign in to comment.