Skip to content

Commit

Permalink
Update authorization
Browse files Browse the repository at this point in the history
  • Loading branch information
mizhm committed Aug 26, 2021
1 parent 56dbad8 commit b137a22
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 4 deletions.
10 changes: 10 additions & 0 deletions Backend/Areas/Admin/Data/BaseController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,16 @@ protected override void OnAuthorization(AuthorizationContext filterContext)
};
}

if (obj != null && (obj.RoleId == 2 || obj.RoleId == 1) && (string)currentArea == "" && currentController == "Transactions" && !Request.IsAjaxRequest())
{
filterContext.Result = new RedirectToRouteResult(new RouteValueDictionary(new RouteValueDictionary(new
{
action = "Index",
controller = "Home",
area = "Admin"
}
)));
}

string[] AllowedController = { "Logout" };
if (obj != null && (obj.RoleId == 2 || obj.RoleId == 1) && (string)currentArea == "" && !AllowedController.Contains(currentAction) && currentController != "Transactions")
Expand Down
2 changes: 1 addition & 1 deletion Backend/Controllers/HomeController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ public ActionResult CheckLogin(string email, string password)
{
obj.AttemptLogin++;
accounts.Update(obj);
errors.Add("Password", "Your password is wrong!" + obj.AttemptLogin);
errors.Add("Password", "Your password is wrong!");

return Json(new
{
Expand Down
4 changes: 2 additions & 2 deletions Backend/Web.config
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@
</assemblyBinding>
</runtime>
<connectionStrings>
<add name="DBConnectionString" connectionString="server=.;database=OnlineBanking;uid=sa;pwd=123456aA@;MultipleActiveResultSets=true" providerName="System.Data.SqlClient" />
<!--<add name="DBConnectionString" connectionString="server=14.231.185.26;database=OnlineBanking;uid=sa;pwd=123456aA@;MultipleActiveResultSets=true" providerName="System.Data.SqlClient" />-->
<!--<add name="DBConnectionString" connectionString="server=.;database=OnlineBanking;uid=sa;pwd=123456aA@;MultipleActiveResultSets=true" providerName="System.Data.SqlClient" />-->
<add name="DBConnectionString" connectionString="server=14.231.185.26;database=OnlineBanking;uid=sa;pwd=123456aA@;MultipleActiveResultSets=true" providerName="System.Data.SqlClient" />
</connectionStrings>
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />
Expand Down
10 changes: 9 additions & 1 deletion OnlineBanking.DAL/Common/Utils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,15 @@ public static string HashPassword(string password)

public static bool ValidatePassword(string password, string correctHash)
{
return BCrypt.Net.BCrypt.Verify(password, correctHash);
try
{
return BCrypt.Net.BCrypt.Verify(password, correctHash);
}
catch (Exception)
{
return false;
}

}
}
}

0 comments on commit b137a22

Please sign in to comment.