public Guid Register(PassportModel model)
        {
            var passport = _passportSearchRepository.GetPassportByName(model.UserName);

            if (passport != null)
            {
                return(Guid.Empty);
            }
            SubscriberEntity subscriber = new SubscriberEntity
            {
                Id         = Guid.NewGuid(),
                CreateTime = DateTime.Now,
                Name       = model.UserName
            };
            var addSubscriber = _subscriberRepository.AddSubscriber(subscriber);

            if (!addSubscriber)
            {
                return(Guid.Empty);
            }
            passport = new PassportEntity
            {
                UserName     = model.UserName,
                Password     = _encrypt.Encrypt(model.Password),
                SubscriberId = subscriber.Id
            };

            return(_passportRepository.AddPassport(passport) ? subscriber.Id : Guid.Empty);
        }
Exemple #2
0
        public string Login(PassportModel model)
        {
            var passport = _passportSearchRepository.GetPassportByName(model.UserName);

            if (passport == null)
            {
                return(string.Empty);
            }
            var verify = passport.VerifyPassword(_encrypt.Encrypt(model.Password));

            if (!verify)
            {
                return(string.Empty);
            }
            var signIn = passport.CreateSignIn(passport.Id);

            _signInRepository.AddSignIn(signIn);
            return(signIn.Token);
        }