protected async Task ReSendEmail()
        {
            RequestInProgress = true;

            try
            {
                var result = await AuthSvc.ResendVerifiEmailAsync(new SvcData
                {
                    LoginEmail = UserEmail
                });

                if (result)
                {
                    TriesCount++;
                }
            }
            catch (Exception ex)
            {
                ErrorMessage = ex.Message;
            }
            finally
            {
                RequestInProgress = false;
            }
        }
Example #2
0
        public ActionResult Edit(int id, int?seasonId = null)
        {
            var union = unionsRepo.GetById(id);

            if (union.IsArchive)
            {
                return(RedirectToAction("NotFound", "Error"));
            }

            if (User.IsInAnyRole(AppRole.Workers) && !AuthSvc.AuthorizeUnionByIdAndManagerId(id, AdminId))
            {
                return(RedirectToAction("Index", "NotAuthorized"));
            }

            var seasons = seasonsRepository.GetSeasonsByUnion(id).ToList();

            Session["CurrentUnionId"] = id;

            var model = new EditUnionForm
            {
                UnionId     = id,
                UnionName   = union.Name,
                SectionId   = union.Section.SectionId,
                SectionName = union.Section.Name,
                IsCatchBall = union.Section.Alias == GamesAlias.NetBall,
                SeasonId    = seasonId ?? GetUnionCurrentSeasonFromSession(),
                Seasons     = seasons
            };

            return(View(model));
        }
Example #3
0
        public async Task ValidateUser()
        {
            try
            {
                vValidatedUser = await AuthSvc.LoginAsync(new SvcData
                {
                    LoginEmail = LoginDetails.LoginEmail,
                    LoginPass  = LoginDetails.LoginPass
                });

                if (vValidatedUser == null)
                {
                    LoginMesssage = "Invalid User Email or Password";
                    return;
                }
                if (vValidatedUser.IsVerified)
                {
                    await((CustomAuthStateProvider)AuthStateProvider).MarkUserAsAuthenticated(vValidatedUser);
                    NavigationManager.NavigateTo("/Index");
                }
                else
                {
                    VerifyDialog.UserEmail = LoginDetails.LoginEmail;
                    VerifyDialog.ShowPopUp();
                }
            }
            catch (Exception ex)
            {
                LoginMesssage = ex.Message;
            }
        }
Example #4
0
        protected async override Task OnInitializedAsync()
        {
            LoginDetails   = new SvcData();
            vValidatedUser = new AppUser();

            PageClaimsPrincipal = (await AuthStateTask).User;
            if (PageClaimsPrincipal.Identity.IsAuthenticated)
            {
                NavigationManager.NavigateTo("/Index");
            }

            if (!string.IsNullOrEmpty(PageCode))
            {
                try
                {
                    await AuthSvc.VerifyEmailAsync(new SvcData
                    {
                        VerificationCode = PageCode
                    });

                    VerifySuccess.Show();
                }
                catch (Exception ex)
                {
                    LoginMesssage = ex.Message;
                }
            }
        }
Example #5
0
 public ActionResult EditTeam(int teamId, int clubId, int seasonId, int sectionId)
 {
     if (User.IsInRole(AppRole.Workers) && AuthSvc.AuthorizeTeamByIdAndManagerId(teamId, base.AdminId))
     {
         return(RedirectToAction("Index", "NotAuthorized"));
     }
     else
     {
         var team = teamRepo.GetById(teamId);
         if (team.IsArchive)
         {
             return(RedirectToAction("NotFound", "Error"));
         }
         var vm = new TeamNavView
         {
             SeasonId    = seasonId,
             TeamName    = team.Title,
             IsValidUser = User.IsInAnyRole(AppRole.Admins, AppRole.Editors),
             TeamId      = team.TeamId,
             leagues     = leagueRepo.GetByTeamAndSeasonShort(teamId, seasonId),
             clubs       = clubsRepo.GetByTeamAndSeasonShort(teamId, seasonId),
             SectionId   = sectionId
         };
         ViewBag.ClubId = clubId;
         return(View("EditTeamClub", vm));
     }
 }
Example #6
0
        public async Task <bool> ValidateUser()
        {
            vValidatedUser = await AuthSvc.LoginAsync(LoginDetails);

            if (vValidatedUser.EmailID != null)
            {
                await((CustomAuthStateProvider)AuthStateProvider).MarkUserAsAuthenticated(vValidatedUser);
                NavigationManager.NavigateTo("/Index");
            }
            else
            {
                LoginMesssage = "Invalid username or password";
            }
            return(await Task.FromResult(true));
        }
Example #7
0
        public ActionResult Edit(int id, int?seasonId)
        {
            bool isAdminsRole     = User.IsInAnyRole(AppRole.Admins, AppRole.Editors);
            bool isNotValidWorker = (User.IsInRole(AppRole.Workers) && !AuthSvc.AuthorizeLeagueByIdAndManagerId(id, AdminId));

            if (isNotValidWorker)
            {
                return(RedirectToAction("Index", "NotAuthorized"));
            }
            var item = leagueRepo.GetById(id);

            if (item.IsArchive)
            {
                return(RedirectToAction("NotFound", "Error"));
            }


            var section = secRepo.GetByLeagueId(item.LeagueId);
            var vm      = new LeagueNavView
            {
                LeagueId     = item.LeagueId,
                LeagueName   = item.Name,
                UnionId      = item.UnionId,
                ClubId       = item.ClubId,
                SectionId    = section.SectionId,
                SectionAlias = section.Alias,
                UnionName    = item.Union == null ? string.Empty : item.Union.Name,
                ClubName     = item.Club == null ? string.Empty : item.Club.Name,
                IsUnionValid = isAdminsRole,
                SeasonId     = seasonId ?? item.SeasonId ?? getCurrentSeason().Id
            };

            Session["desOrder"] = false;
            if (!isAdminsRole)
            {
                if (vm.UnionId != null)
                {
                    vm.IsUnionValid = AuthSvc.AuthorizeUnionByIdAndManagerId(vm.UnionId.Value, base.AdminId);
                }
            }

            return(View(vm));
        }
Example #8
0
        public ActionResult Edit(int id, int?seasonId, int?unionId)
        {
            if (User.IsInRole(AppRole.Workers) && !AuthSvc.AuthorizeTeamByIdAndManagerId(id, base.AdminId))
            {
                return(RedirectToAction("Index", "NotAuthorized"));
            }
            else
            {
                if (!seasonId.HasValue)
                {
                    seasonId = teamRepo.GetSeasonIdByTeamId(id);
                }
                var team = teamRepo.GetById(id, seasonId);

                if (team.IsArchive)
                {
                    return(RedirectToAction("NotFound", "Error"));
                }

                var userLeagues = AuthSvc.FindLeaguesByTeamAndManagerId(id, base.AdminId);

                var vm = new TeamNavView
                {
                    TeamId      = id,
                    TeamName    = team.Title,
                    IsValidUser = User.IsInAnyRole(AppRole.Admins, AppRole.Editors),
                    leagues     = leagueRepo.GetByTeamAndSeasonShort(id, seasonId.Value),
                    UserLeagues = userLeagues.Select(ul => new LeagueShort {
                        Id = ul.LeagueId, Name = ul.Name, UnionId = ul.UnionId, Check = true
                    }).ToList(),
                    SeasonId = seasonId.Value,
                    clubs    = clubsRepo.GetByTeamAndSeasonShort(id, seasonId.Value),
                    UnionId  = unionId,
                    JobRole  = usersRepo.GetTopLevelJob(AdminId)
                };

                return(View(vm));
            }
        }
        protected async Task UpdateNSendEmail()
        {
            try
            {
                var result = await AuthSvc.UpdateNSendVerifiEmailAsync(new SvcData
                {
                    LoginEmail  = UserEmail,
                    ComplexData = JsonSerializer.Serialize(new AppUser {
                        UserEmail = NewUserEmail
                    })
                });

                if (result)
                {
                    UserEmail = NewUserEmail;
                    EditEmailPopUp.Hide();
                }
            }
            catch (Exception ex)
            {
                ErrorMessage = ex.Message;
            }
        }
Example #10
0
        public ActionResult Edit(int id = 0, int seasonId = 0, int leagueId = 0, int clubId = 0, int teamId = 0)
        {
            //
            Thread.CurrentThread.CurrentCulture = new CultureInfo("he-IL");
            var vm = new PlayerFormView
            {
                LeagueId = leagueId,
                Genders  = new SelectList(usersRepo.GetGenders(), "GenderId", "Title")
            };

            if (id != 0)
            {
                vm.ClubId        = clubId;
                vm.CurrentTeamId = teamId;
                vm.SeasonId      = seasonId;

                if (leagueId > 0)
                {
                    League league = leagueRepo.GetById(leagueId);
                    if (league != null)
                    {
                        vm.IsHadicapEnabled = league.Union.IsHadicapEnabled;
                        vm.SeasonId         = league.SeasonId ?? vm.SeasonId;
                    }
                }

                User pl = usersRepo.GetById(id);
                if (pl == null && pl.IsArchive)
                {
                    return(RedirectToAction("NotFound", "Error"));
                }


                if (teamId > 0)
                {
                    TeamsPlayer teamsPlayer = pl.TeamsPlayers
                                              .FirstOrDefault(x => x.UserId == pl.UserId &&
                                                              x.SeasonId == vm.SeasonId &&
                                                              x.TeamId == teamId);
                    if (teamsPlayer == null)
                    {
                        return(RedirectToAction("NotFound", "Error"));
                    }

                    vm.HandicapLevel = teamsPlayer.HandicapLevel;
                    vm.IsPlayereInTeamLessThan3year = teamsPlayer.IsPlayereInTeamLessThan3year;
                    vm.NumberOfTeamsUserPlays       = pl.TeamsPlayers.Count;
                }

                vm.InjectFrom <IgnoreNulls>(pl);

                if (!string.IsNullOrEmpty(pl.Password))
                {
                    vm.Password = Protector.Decrypt(pl.Password);
                }
                vm.IsValidUser     = User.IsInAnyRole(AppRole.Admins, AppRole.Editors);
                vm.ManagerTeams    = new List <TeamDto>();
                vm.PlayerTeams     = new List <TeamDto>();
                vm.PlayerHistories = new List <PlayerHistoryFormView>();

                var currDate = DateTime.Now;
                if (pl.UsersType.TypeRole == AppRole.Players)
                {
                    List <TeamDto> teams = pl.TeamsPlayers.Where(t => !t.Team.IsArchive &&
                                                                 seasonsRepository.GetAllCurrent().Select(s => s.Id).Contains(t.SeasonId ?? 0))
                                           .Select(t => new TeamDto
                    {
                        TeamId   = t.TeamId,
                        Title    = t.Team.Title,
                        SeasonId = t.SeasonId,
                        ClubId   = t.Team.ClubTeams.Where(ct => ct.SeasonId == t.SeasonId).FirstOrDefault()?.ClubId ?? 0,
                        LeagueId = t.Team.LeagueTeams.Where(lt => lt.SeasonId == t.SeasonId).FirstOrDefault()?.LeagueId ?? 0
                    })
                                           .ToList();
                    vm.PlayerTeams = teams;
                    if (!vm.IsValidUser)
                    {
                        var managerTeams = AuthSvc.FindTeamsByManagerId(base.AdminId)
                                           .Select(t => new {
                            TeamId = t.TeamId,
                            Title  = t.Title,
                            Club   = teamRepo.GetClubByTeamId(t.TeamId, currDate),
                            League = teamRepo.GetLeagueByTeamId(t.TeamId, currDate)
                        })
                                           .Select(t => new TeamDto
                        {
                            TeamId   = t.TeamId,
                            Title    = t.Title,
                            SeasonId = t.League.SeasonId ?? t.Club?.SeasonId,
                            ClubId   = t.Club?.ClubId ?? 0,
                            LeagueId = t.League?.LeagueId ?? 0
                        });
                        vm.ManagerTeams = managerTeams;
                    }
                }

                vm.PlayerHistories = usersRepo.GetPlayerHistory(id, vm.SeasonId).ToViewModel();
            }

            if (TempData["ViewData"] != null)
            {
                ViewData = (ViewDataDictionary)TempData["ViewData"];
            }

            return(View(vm));
        }