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 TokenValidation Validate(TokenInfoRealm tokenInfo) { if (tokenInfo == null) { return(TokenValidation.UNEXPECTED_TOKEN_INFO_FORMAT); } return(!this.ValidateUserRole(tokenInfo) ? TokenValidation.INVALID_USER_ROLE : TokenValidation.VALID); }
public void UpdateTokenData(ProfileRealm profile, TokenData tokenData) { TokenInfoRealm tokenInfoRealm = (TokenInfoRealm)JsonConvert.DeserializeObject <TokenInfoRealm>(TokenDecoder.Decode(tokenData.AccessToken)); profile.TokenInfo = tokenInfoRealm; this.AddOrUpdate(profile, (Action <ProfileRealm>)null); this._secureStore.SaveTokenData(profile.Id, tokenData); }
public string GetProfileIdFromTokenData(TokenInfoRealm tokenInfo) { string str = string.Format("{0}-{1}-{2}_{3}", (object)tokenInfo.InstituteCode, (object)tokenInfo.InstituteUserId, (object)tokenInfo.SchoolYearId, (object)tokenInfo.Role); if (!string.IsNullOrWhiteSpace(tokenInfo.TutelaryId)) { str = str + "-" + tokenInfo.TutelaryId; } return(str); }
private void DeleteOldSchoolYearIdProfiles(TokenInfoRealm tokenInfo) { List <ProfileRealm> list = this._profileDataService.GetProfiles().Where <ProfileRealm>((Func <ProfileRealm, bool>)(x => x.TokenInfo?.InstituteCode == tokenInfo.InstituteCode && x.TokenInfo?.SchoolYearId != tokenInfo?.SchoolYearId)).ToList <ProfileRealm>(); int num = list.Count <ProfileRealm>(); for (int index = 0; index < num; ++index) { this.DeleteProfile(list[index]); } }
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); }
public IQueryable <ProfileRealm> ToRealmResults(Realm realm) { TokenInfoRealm tokenInfo = ((IQueryable <TokenInfoRealm>)realm.All <TokenInfoRealm>()).Where <TokenInfoRealm>((Expression <Func <TokenInfoRealm, bool> >)(x => x.UserId == this._userId && x.Role == this._userRole && x.InstituteUserId == this._instituteUserId)).FirstOrDefault <TokenInfoRealm>(); return(((IQueryable <ProfileRealm>)realm.All <ProfileRealm>()).Where <ProfileRealm>((Expression <Func <ProfileRealm, bool> >)(x => x.TokenInfo == tokenInfo))); }
private bool ValidateUserRole(TokenInfoRealm tokenInfo) { return(tokenInfo.Role == 0 || tokenInfo.Role == 1); }
public ProfileRealm GetProfileByComplexKey(TokenInfoRealm tokenInfo) { return(this._profileRepository.Query().FirstOrDefault <ProfileRealm>((Expression <Func <ProfileRealm, bool> >)(x => x.TokenInfo.InstituteUserId == tokenInfo.InstituteUserId && x.TokenInfo.TutelaryId == tokenInfo.TutelaryId && x.TokenInfo.InstituteCode == tokenInfo.InstituteCode && x.TokenInfo.SchoolYearId == tokenInfo.SchoolYearId))); }
public ProfileRealm GetProfile(TokenInfoRealm tokenInfo) { return(this._profileRepository.Query().FirstOrDefault <ProfileRealm>((Expression <Func <ProfileRealm, bool> >)(x => x.TokenInfo.UserId == tokenInfo.UserId && x.TokenInfo.Role == tokenInfo.Role && x.TokenInfo.InstituteUserId == tokenInfo.InstituteUserId))); }