// Login logs a user in.
Login logs a user in.
// Login logs a user in .
func (s *Service) Login(c context.Context, req *authpb.LoginRequest) (*authpb.LoginResponse, error) {
	s.Logger.Info("received code", zap.String("code", req.Code))
	openID, err := s.OpenIDResolver.Resolve((req.Code))
	if err != nil {
		return nil, status.Errorf(codes.Unavailable, "cannot resolve openid: %v", err)
	}
	accountID, err := s.Mongo.ResolveAccountID(c, openID)
	if err != nil {
		s.Logger.Error("cannot resolve account id ", zap.Error(err))
		return nil, status.Errorf(codes.Internal, "")
	}
	tkn, err := s.TokenGenerator.GenerateToken(accountID.String(), s.TokenExpire)
	if err != nil {
		s.Logger.Error("cannot generate token", zap.Error(err))
		return nil, status.Error(codes.Internal, "")
	}
	return &authpb.LoginResponse{
		AccessToken: tkn,
		ExpiresIn:   int32(s.TokenExpire.Seconds()),
	}, nil
}
func ( s * Service ) Login ( c context . Context , req * authpb . LoginRequest ) ( * authpb . LoginResponse , error ) { s . Logger . Info ( " " , zap . String ( " " , req . Code ) ) openID , err := s . OpenIDResolver . Resolve ( ( req . Code ) ) if err != nil { return nil , status . Errorf ( codes . Unavailable , " " , err ) } accountID , err := s . Mongo . ResolveAccountID ( c , openID ) if err != nil { s . Logger . Error ( " " , zap . Error ( err ) ) return nil , status . Errorf ( codes . Internal , " " ) } tkn , err := s . TokenGenerator . GenerateToken ( accountID . String ( ) , s . TokenExpire ) if err != nil { s . Logger . Error ( " " , zap . Error ( err ) ) return nil , status . Error ( codes . Internal , " " ) } return & authpb . LoginResponse { AccessToken : tkn , ExpiresIn : int32 ( s . TokenExpire . Seconds ( ) ) , } , nil }
Login logs a user in.
Login logs a user in .