Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Crypt print in artisan command #104

Merged
merged 3 commits into from
Apr 26, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions crypt/aes.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"encoding/json"
"errors"
"io"
"os"

"github.com/gookit/color"

Expand All @@ -21,6 +22,13 @@ type AES struct {
// NewAES returns a new AES hasher.
func NewAES() *AES {
key := facades.Config.GetString("app.key")

// Don't use AES in artisan key:generate command
args := os.Args
if len(args) >= 3 && args[1] == "artisan" && args[2] == "key:generate" {
return nil
}

// check key length before using it
if len(key) != 16 && len(key) != 24 && len(key) != 32 {
color.Redln("[Crypt] Empty or invalid APP_KEY, please reset it.\nRun command:\ngo run . artisan key:generate")
Expand Down