YAFLogo

Posted by: McHine - Friday, 20 December 2024 01:51:28
Looking to expose the roles in order to do some authorisation control. Seems using boardcontext I can get most of the existing ones .membershipuser .isforumadmin etc (please correct if i'm wrong). I have added two (Crew and Owner if you want to know), and want to access those to change website behaviours. How to? Thanks a millon!

Posted by: tha_watcha - Friday, 20 December 2024 08:12:27
If you want to check if the Current user is part of a role use ... [code=csharp]​await BoardContext.Current.Get<IAspNetUsersHelper>().IsUserInRoleAsync(BoardContext.Current.MembershipUser, "Crew");[/code]

Posted by: McHine - Thursday, 2 January 2025 23:40:11
ok that is working pretty well, for example currently using this in pages needing to have user logged in: bool RegUser = await BoardContext.Current.Get().IsUserInRoleAsync(BoardContext.Current.MembershipUser, "Registered Users"); if (!RegUser) { Nav.NavigateTo("/Forums/Account/Login", true); } but..... what about banned and suspended users, are they considered Registered Users? probably a noob question or easily found (happy to be shown where to look for this kind of thing, struggling with trawling so asking early!) thanks again getting closer and closer to first looks :)

Posted by: tha_watcha - Friday, 3 January 2025 06:27:10
if you want to check if the user is registered just check for guest [code=csharp]​if (BoardContext.Current.IsGuest) {     Nav.NavigateTo("/Forums/Account/Login", true); }[/code] Banned Users are deleted users and are treated as guest, and as suspended users they only see a blank page.