private void AuthtokenLogin()
        {
            using (var db = new retrospyContext())
            {
                var info = from u in db.Users
                           join p in db.Profiles on u.Userid equals p.Userid
                           join n in db.Subprofiles on p.Profileid equals n.Profileid
                           where n.Authtoken == _session.UserData.AuthToken &&
                           n.Partnerid == _session.UserData.PartnerID &&
                           n.Namespaceid == _session.UserData.NamespaceID
                           select new LoginDBResult
                {
                    Email             = u.Email,
                    UserID            = u.Userid,
                    ProfileID         = p.Profileid,
                    SubProfileID      = n.Subprofileid,
                    Nick              = p.Nick,
                    UniqueNick        = n.Uniquenick,
                    PasswordHash      = u.Password,
                    NamespaceID       = n.Namespaceid,
                    EmailVerifiedFlag = (bool)u.Emailverified,
                    BannedFlag        = u.Banned
                };

                if (info.Count() != 1)
                {
                    _errorCode = GPError.LoginBadPreAuth;
                    return;
                }
                _result = info.First();
            }
        }
        private void NickEmailLogin()
        {
            //Check email existence
            using (var db = new retrospyContext())
            {
                var email = from u in db.Users
                            where u.Email == _session.UserData.Email
                            select u.Userid;

                if (email.Count() == 0)
                {
                    _errorCode = GPError.LoginBadEmail;
                    return;
                }

                //Grab information from database
                // default namespace id = 0
                var info = from u in db.Users
                           join p in db.Profiles on u.Userid equals p.Userid
                           join n in db.Subprofiles on p.Profileid equals n.Profileid
                           where u.Email == _session.UserData.Email &&
                           p.Nick == _session.UserData.Nick &&
                           n.Namespaceid == _request.NamespaceID
                           select new LoginDBResult
                {
                    Email             = u.Email,
                    UserID            = u.Userid,
                    ProfileID         = p.Profileid,
                    SubProfileID      = n.Subprofileid,
                    Nick              = p.Nick,
                    UniqueNick        = n.Uniquenick,
                    PasswordHash      = u.Password,
                    NamespaceID       = n.Namespaceid,
                    EmailVerifiedFlag = (bool)u.Emailverified,
                    BannedFlag        = u.Banned
                };

                if (info.Count() != 1)
                {
                    _errorCode = GPError.LoginBadProfile;
                    return;
                }
                _result = info.First();
            }
        }