slaventius 2 years ago
parent 738d3a0269
commit d52f1409aa
  1. 2
      go.mod
  2. 2
      go.sum
  3. 5
      internal/auth.go
  4. 13
      internal/transport/grpc/grpc.go

@ -3,7 +3,7 @@ module git.slaventius.ru/test3k/auth
go 1.19
require (
git.slaventius.ru/test3k/umate v0.0.0-20230204104415-6dd680567696
git.slaventius.ru/test3k/umate v0.0.0-20230209054131-c039ab837f14
github.com/go-chi/chi/v5 v5.0.8
github.com/kelseyhightower/envconfig v1.4.0
google.golang.org/grpc v1.52.3

@ -1,5 +1,7 @@
git.slaventius.ru/test3k/umate v0.0.0-20230204104415-6dd680567696 h1:amkq2DrSdfXKquTYFBm+nBBXAfjqjg8UAYactSKeQWM=
git.slaventius.ru/test3k/umate v0.0.0-20230204104415-6dd680567696/go.mod h1:zC+pjeBAFo0eLwPt+vBrdyt1ObAPU+HMfDG12vXLjBA=
git.slaventius.ru/test3k/umate v0.0.0-20230209054131-c039ab837f14 h1:1GAmFzUQriRn/WfplqIYHKuHF/TDzYfy9D8unxmC8wQ=
git.slaventius.ru/test3k/umate v0.0.0-20230209054131-c039ab837f14/go.mod h1:zC+pjeBAFo0eLwPt+vBrdyt1ObAPU+HMfDG12vXLjBA=
github.com/go-chi/chi/v5 v5.0.8 h1:lD+NLqFcAi1ovnVZpsnObHGW4xb4J8lNmoYVfECH1Y0=
github.com/go-chi/chi/v5 v5.0.8/go.mod h1:DslCQbL2OYiznFReuXYUmQ2hGd1aDpCnlMNITLSKoi8=
github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=

@ -60,7 +60,8 @@ func registration(s *AuthServer) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
uid := r.FormValue("uid")
email := r.FormValue("email")
code, err := s.db.Registration(uid, email)
password := r.FormValue("password")
_, err := s.db.Registration(uid, email, password)
if err != nil {
status := status.Convert(err)
w.Write([]byte(status.Message()))
@ -68,7 +69,7 @@ func registration(s *AuthServer) http.HandlerFunc {
return
}
w.Write([]byte(fmt.Sprintf("Success registration for %s with code %s", uid, code)))
w.Write([]byte(fmt.Sprintf("Success registration for %s", uid)))
}
}

@ -52,13 +52,14 @@ func (s *AuthDBClient) Login(uid string, password string) error {
return err
}
return err
return nil
}
func (s *AuthDBClient) Registration(uid string, email string) (string, error) {
func (s *AuthDBClient) Registration(uid string, email string, password string) (string, error) {
res, err := s.db.Registration(s.ctx, &api.RegistrationRequest{
Login: uid,
Email: email,
Login: uid,
Password: password,
Email: email,
})
//
@ -66,7 +67,7 @@ func (s *AuthDBClient) Registration(uid string, email string) (string, error) {
return "", err
}
return res.GetCode(), err
return res.GetCode(), nil
}
func (s *AuthDBClient) Confirmation(code string) error {
@ -79,5 +80,5 @@ func (s *AuthDBClient) Confirmation(code string) error {
return err
}
return err
return nil
}

Loading…
Cancel
Save