package auth import ( "context" "git.ostiwe.com/ostiwe-com/status/modules/jwt" "git.ostiwe.com/ostiwe-com/status/repository" "golang.org/x/crypto/bcrypt" ) type Module struct { userRepository repository.User } func New() Module { return Module{ userRepository: repository.NewUserRepository(), } } func (m *Module) Proceed(ctx context.Context, login, password string) (*string, error) { lightweightUser, err := m.userRepository.FindByLogin(ctx, login) if err != nil { return nil, err } err = bcrypt.CompareHashAndPassword([]byte(lightweightUser.Password), []byte(password)) if err != nil { return nil, err } jwtString, err := jwt.CreateByUser(lightweightUser) if err != nil { return nil, err } return &jwtString, nil }