diff --git a/Sevomin.WebFrontend.Controllers/AccountController.cs b/Sevomin.WebFrontend.Controllers/AccountController.cs index 9f158ec..3f5825e 100644 --- a/Sevomin.WebFrontend.Controllers/AccountController.cs +++ b/Sevomin.WebFrontend.Controllers/AccountController.cs @@ -245,7 +245,7 @@ namespace Sevomin.WebFrontend.Controllers } - [Authorize] + [Authorize(Roles = "Avalin,Dovomin")] public async Task MyProfile(bool? success) { if (success.HasValue) @@ -266,7 +266,7 @@ namespace Sevomin.WebFrontend.Controllers } } - [Authorize] + [Authorize(Roles = "Dovomin")] [HttpPost] public async Task ProfileDovomin(string JalaliBirthDate, string FirstName, string LastName, string ContactPersonEMail, bool IsFullTime, @@ -314,7 +314,7 @@ namespace Sevomin.WebFrontend.Controllers } } - [Authorize] + [Authorize(Roles = "Avalin")] [HttpPost] public async Task ProfileAvalin(string CompanyName, string NationalId, string RegisterId, string Address, string CompanyPhoneNumber, string EMail) @@ -350,23 +350,27 @@ namespace Sevomin.WebFrontend.Controllers if ((user as Dovomin) == null) return HttpNotFound(); - if (User.IsInRole("Dovomin")) + if (!User.IsInRole("God")) { - if (userId != user.Id) + if (User.IsInRole("Dovomin")) { - return HttpNotFound(); + if (userId != user.Id) + { + return HttpNotFound(); + } + else { } + } + else if (User.IsInRole("Avalin")) + { + Avalin avalin = (await UserManager.FindByNameAsync(User.Identity.Name)) as Avalin; + bool showIt = avalin.Jobs.Any(j => + { + bool ret = j.Applications.Any(c => c.DovominId == userId); + return ret; + }); + if (!showIt) + return HttpNotFound(); } - else { } - } - else if (User.IsInRole("Avalin")) - { - Avalin avalin = (await UserManager.FindByNameAsync(User.Identity.Name)) as Avalin; - bool showIt = avalin.Jobs.Any(j => { - bool ret = j.Applications.Any(c => c.DovominId == userId); - return ret; - }); - if (!showIt) - return HttpNotFound(); } return View(new DovominViewModel(user as Dovomin)); diff --git a/Sevomin.WebFrontend.Controllers/AuthorizedController.cs b/Sevomin.WebFrontend.Controllers/AuthorizedController.cs index 582c073..a70ea40 100644 --- a/Sevomin.WebFrontend.Controllers/AuthorizedController.cs +++ b/Sevomin.WebFrontend.Controllers/AuthorizedController.cs @@ -4,6 +4,7 @@ using Sevomin.Models.Helpers; using System.IO; using System.Threading.Tasks; using System.Web.Mvc; +using System.Linq; namespace Sevomin.WebFrontend.Controllers { @@ -27,10 +28,32 @@ namespace Sevomin.WebFrontend.Controllers if (string.IsNullOrWhiteSpace(userid)) userid = (await UserManager.FindByNameAsync(User.Identity.Name)).Id; Dovomin user = await UserManager.FindByIdAsync(userid) as Dovomin; - if (user == null) return HttpNotFound(); - //ToDo: فکر کنم هر کسی که لاگ این کرده باشه میتونه رزومه هر کسی را دانلود کنه + + if (!User.IsInRole("God")) + { + if (User.IsInRole("Dovomin")) + { + if (userid != user.Id) + { + return HttpNotFound(); + } + else { } + } + else if (User.IsInRole("Avalin")) + { + Avalin avalin = (await UserManager.FindByNameAsync(User.Identity.Name)) as Avalin; + bool showIt = avalin.Jobs.Any(j => + { + bool ret = j.Applications.Any(c => c.DovominId == userid); + return ret; + }); + if (!showIt) + return HttpNotFound(); + } + } + string path = Path.Combine(Server.MapPath("~/App_Data/resumes/"), english ? user.EnglishResume : user.PersianResume); string fileDownloadName = string.Format("{0} {1} Resume{2}", user.DisplayName, english ? "English" : "Persian", Path.GetExtension(path)); return File(path, "application/octet-stream", fileDownloadName); diff --git a/Sevomin.WebFrontend.Controllers/HomeController.cs b/Sevomin.WebFrontend.Controllers/HomeController.cs index 5c2d086..7f6893e 100644 --- a/Sevomin.WebFrontend.Controllers/HomeController.cs +++ b/Sevomin.WebFrontend.Controllers/HomeController.cs @@ -27,10 +27,12 @@ namespace Sevomin.WebFrontend.Controllers else { User user = await UserManager.FindByNameAsync(User.Identity.Name); - if (user is Avalin) - return View("AvalinIndex"); - else - return View("DovominIndex"); + if (user is Avalin) + return View("AvalinIndex"); + else if (user is Dovomin) + return View("DovominIndex"); + else + return RedirectToAction("Index", "God"); } } diff --git a/Sevomin.WebFrontend.Controllers/Sevomin.WebFrontend.Controllers.csproj b/Sevomin.WebFrontend.Controllers/Sevomin.WebFrontend.Controllers.csproj index 575fd6f..5c89eda 100644 --- a/Sevomin.WebFrontend.Controllers/Sevomin.WebFrontend.Controllers.csproj +++ b/Sevomin.WebFrontend.Controllers/Sevomin.WebFrontend.Controllers.csproj @@ -94,6 +94,7 @@ + diff --git a/Sevomin.WebFrontend/App_Start/RouteConfig.cs b/Sevomin.WebFrontend/App_Start/RouteConfig.cs index ecc33fe..f698f56 100644 --- a/Sevomin.WebFrontend/App_Start/RouteConfig.cs +++ b/Sevomin.WebFrontend/App_Start/RouteConfig.cs @@ -113,6 +113,14 @@ namespace Sevomin.WebFrontend ); #endregion + #region God Mode + routes.MapRoute( + name: "TurnOnGodMode", + url: "god-mode/{action}", + defaults: new { controller = "God", action = "Index" } + ); + #endregion + routes.MapRoute( name: "Default", url: "{controller}/{action}/{id}", diff --git a/Sevomin.WebFrontend/Sevomin.WebFrontend.csproj b/Sevomin.WebFrontend/Sevomin.WebFrontend.csproj index 9408b50..b52ef7f 100644 --- a/Sevomin.WebFrontend/Sevomin.WebFrontend.csproj +++ b/Sevomin.WebFrontend/Sevomin.WebFrontend.csproj @@ -331,6 +331,7 @@ + Web.config diff --git a/Sevomin.WebFrontend/Views/Job/MiniApplication.cshtml b/Sevomin.WebFrontend/Views/Job/MiniApplication.cshtml deleted file mode 100644 index be65dd8..0000000 --- a/Sevomin.WebFrontend/Views/Job/MiniApplication.cshtml +++ /dev/null @@ -1,19 +0,0 @@ -@model Sevomin.Models.JobApplicationViewModel - -
-
- از طرف @Model.DovominDisplayName -

@Model.JobSummary

- @if (!string.IsNullOrWhiteSpace(Model.CoverLetter)) - { -
پیغام متخصص:
-
@Model.CoverLetter
- } - @if (Model.MinimumRequirement){ -

این متخصص تمامی مهارت های الزامی برای این فرصت شغلی را دارد. همچنین میزان مطابقت ایشان با این فرصت شغلی، @Model.Affinity درصد است.

- } - else { -

این متخصص برخی مهارت های الزامی برای این فرصت شغلی را ندارد. همچنین میزان مطابقت ایشان با این فرصت شغلی، @Model.Affinity درصد است.

- } -
-
\ No newline at end of file