public ProfileRealm GetProfile( string instituteCode, int instituteUserId, int roleId) { ProfileRealm activeProfile = this.GetActiveProfile(); return(roleId != 2 ? this._profileRepository.Query().ToList <ProfileRealm>().FirstOrDefault <ProfileRealm>((Func <ProfileRealm, bool>)(x => { ParameterExpression parameterExpression; // ISSUE: reference to a compiler-generated field // ISSUE: reference to a compiler-generated field // ISSUE: method reference // ISSUE: method reference // ISSUE: field reference TokenInfoRealm tokenInfoRealm = this._tokenInfoRepository.Query().FirstOrDefault <TokenInfoRealm>(Expression.Lambda <Func <TokenInfoRealm, bool> >((Expression)Expression.AndAlso((Expression)Expression.OrElse(token.InstituteUserId == this.instituteUserId, (Expression)Expression.Equal(token.TutelaryId, (Expression)Expression.Call(this.instituteUserId, (MethodInfo)MethodBase.GetMethodFromHandle(__methodref(int.ToString)), Array.Empty <Expression>()))), (Expression)Expression.Equal((Expression)Expression.Convert((Expression)Expression.Property((Expression)parameterExpression, (MethodInfo)MethodBase.GetMethodFromHandle(__methodref(TokenInfoRealm.get_Role))), typeof(int)), (Expression)Expression.Field((Expression)Expression.Constant((object)this, typeof(ProfileDbDataService.\u003C\u003Ec__DisplayClass14_0)), FieldInfo.GetFieldFromHandle(__fieldref(ProfileDbDataService.\u003C\u003Ec__DisplayClass14_0.roleId))))), parameterExpression)); InstituteRealm instituteRealm = (InstituteRealm)RealmDb.Instance.Find <InstituteRealm>(instituteCode); return tokenInfoRealm != null && x.Institute == instituteRealm && x.TokenInfo == tokenInfoRealm; })) : (activeProfile.TokenInfo.InstituteUserId == instituteUserId ? activeProfile : this._profileRepository.Query().ToList <ProfileRealm>().FirstOrDefault <ProfileRealm>((Func <ProfileRealm, bool>)(x => { ParameterExpression parameterExpression; // ISSUE: reference to a compiler-generated field // ISSUE: reference to a compiler-generated field // ISSUE: method reference TokenInfoRealm tokenInfoRealm = this._tokenInfoRepository.Query().FirstOrDefault <TokenInfoRealm>(Expression.Lambda <Func <TokenInfoRealm, bool> >((Expression)Expression.OrElse(token.InstituteUserId == this.instituteUserId, (Expression)Expression.Equal(token.TutelaryId, (Expression)Expression.Call(this.instituteUserId, (MethodInfo)MethodBase.GetMethodFromHandle(__methodref(int.ToString)), Array.Empty <Expression>()))), parameterExpression)); InstituteRealm instituteRealm = (InstituteRealm)RealmDb.Instance.Find <InstituteRealm>(instituteCode); return tokenInfoRealm != null && x.Institute == instituteRealm && x.TokenInfo == tokenInfoRealm; })))); }
public async Task <ProfileRealm> Login( InstituteRealm institute, string username, string password) { if (!this.IsInstituteValid(institute)) { throw new InvalidInstitudeDataException(nameof(institute)).SetErrorCode <InvalidInstitudeDataException>("/Users/admin/myagent/macMiniBlack3/_work/2/s/eKreta.Mobile/eKreta.Mobile.Core.Standard/Repository/DataServices/Login/AuthDbDataService.cs", 82); } if (!this.IsUserNameValid(username)) { throw new ArgumentException(nameof(username)); } if (!this.IsPasswordValid(password)) { throw new ArgumentException(nameof(password)); } TokenData tokenAsync = await this._mobileApi.GetTokenAsync(institute.Url, username, password, institute.InstituteCode); TokenInfoRealm tokenInfo = new TokenInfoRealmMapper().To((Ekreta.Mobile.Core.Models.TokenInfo)JsonConvert.DeserializeObject <Ekreta.Mobile.Core.Models.TokenInfo>(TokenDecoder.Decode(tokenAsync.AccessToken))); switch (this._tokenValidator.Validate(tokenInfo)) { case TokenValidation.VALID: this.DeleteOldSchoolYearIdProfiles(tokenInfo); return(this.ProcessValidToken(institute, tokenAsync, tokenInfo)); case TokenValidation.INVALID_USER_ROLE: throw new UserRoleException("Invalid User Role").SetErrorCode <UserRoleException>("/Users/admin/myagent/macMiniBlack3/_work/2/s/eKreta.Mobile/eKreta.Mobile.Core.Standard/Repository/DataServices/Login/AuthDbDataService.cs", 103); default: throw new LoginException("Invalid TokenData").SetErrorCode <LoginException>("/Users/admin/myagent/macMiniBlack3/_work/2/s/eKreta.Mobile/eKreta.Mobile.Core.Standard/Repository/DataServices/Login/AuthDbDataService.cs", 107); } }
public IQueryable <ProfileRealm> ToRealmResults(Realm realm) { ParameterExpression parameterExpression; // ISSUE: method reference TokenInfoRealm tokenInfo = ((IQueryable <TokenInfoRealm>)realm.All <TokenInfoRealm>()).Where <TokenInfoRealm>(Expression.Lambda <Func <TokenInfoRealm, bool> >((Expression)Expression.OrElse(x.InstituteUserId == this._instituteUserId, (Expression)Expression.Equal(x.TutelaryId, (Expression)Expression.Call(this._instituteUserId, (MethodInfo)MethodBase.GetMethodFromHandle(__methodref(int.ToString)), Array.Empty <Expression>()))), parameterExpression)).FirstOrDefault <TokenInfoRealm>(); InstituteRealm institute = (InstituteRealm)realm.Find <InstituteRealm>(this._instituteCode); if (tokenInfo == null) { return(Enumerable.Empty <ProfileRealm>().AsQueryable <ProfileRealm>()); } return(((IQueryable <ProfileRealm>)realm.All <ProfileRealm>()).Where <ProfileRealm>((Expression <Func <ProfileRealm, bool> >)(x => x.Institute == institute && x.TokenInfo == tokenInfo))); }
private ProfileRealm CreateNewProfile( InstituteRealm institute, TokenInfoRealm tokenInfo) { string profileIdFromTokenData = this._tokenValidator.GetProfileIdFromTokenData(tokenInfo); return(new ProfileRealm() { Id = profileIdFromTokenData, TokenInfo = tokenInfo, Institute = institute }); }
public IQueryable <ProfileRealm> ToRealmResults(Realm realm) { ParameterExpression parameterExpression; // ISSUE: method reference // ISSUE: method reference // ISSUE: field reference TokenInfoRealm tokenInfo = ((IQueryable <TokenInfoRealm>)realm.All <TokenInfoRealm>()).Where <TokenInfoRealm>(Expression.Lambda <Func <TokenInfoRealm, bool> >((Expression)Expression.AndAlso((Expression)Expression.OrElse(x.InstituteUserId == this._instituteUserId, (Expression)Expression.Equal(x.TutelaryId, (Expression)Expression.Call(this._instituteUserId, (MethodInfo)MethodBase.GetMethodFromHandle(__methodref(int.ToString)), Array.Empty <Expression>()))), (Expression)Expression.Equal((Expression)Expression.Convert((Expression)Expression.Property((Expression)parameterExpression, (MethodInfo)MethodBase.GetMethodFromHandle(__methodref(TokenInfoRealm.get_Role))), typeof(int)), (Expression)Expression.Field((Expression)Expression.Constant((object)this, typeof(GetProfileByUserIdAndInstituteCodeSpecification)), FieldInfo.GetFieldFromHandle(__fieldref(GetProfileByUserIdAndInstituteCodeSpecification._userRole))))), parameterExpression)).FirstOrDefault <TokenInfoRealm>(); InstituteRealm institute = (InstituteRealm)realm.Find <InstituteRealm>(this._instituteCode); if (tokenInfo == null) { return(Enumerable.Empty <ProfileRealm>().AsQueryable <ProfileRealm>()); } return(((IQueryable <ProfileRealm>)realm.All <ProfileRealm>()).Where <ProfileRealm>((Expression <Func <ProfileRealm, bool> >)(x => x.Institute == institute && x.TokenInfo == tokenInfo))); }
private ProfileRealm ProcessValidToken( InstituteRealm institute, TokenData tokenData, TokenInfoRealm tokenInfo) { ProfileRealm profile = this._profileDataService.GetProfile(this._tokenValidator.GetProfileIdFromTokenData(tokenInfo)) ?? this.CreateNewProfile(institute, tokenInfo); this._profileDataService.UpdateTokenData(profile, tokenData); if (profile == null) { throw new LoginException("Can't create profile. Profile was null in ProcessValidToken(TokenData)").SetErrorCode <LoginException>("/Users/admin/myagent/macMiniBlack3/_work/2/s/eKreta.Mobile/eKreta.Mobile.Core.Standard/Repository/DataServices/Login/AuthDbDataService.cs", 232); } this._profileDataService.SetActiveProfile(profile); return(profile); }
private bool IsInstituteValid(InstituteRealm institute) { return(institute != null && !string.IsNullOrWhiteSpace(institute.InstituteCode) && (!string.IsNullOrWhiteSpace(institute.InstituteId) && !string.IsNullOrWhiteSpace(institute.Url)) && Uri.IsWellFormedUriString(institute.Url, UriKind.Absolute)); }