Тёмный

Managing User Roles - A TimCo Retail Manager Video 

IAmTimCorey
Подписаться 421 тыс.
Просмотров 23 тыс.
50% 1

Опубликовано:

 

5 окт 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 99   
@99MrX99
@99MrX99 5 лет назад
Great video as always :) One small tip for adding methods from a class to the interface: You can press Ctrl + . on the method name and choose "Pull up to Interface X.."
@jfgreco15
@jfgreco15 5 лет назад
I was just going to suggest the same thing!
@IAmTimCorey
@IAmTimCorey 5 лет назад
Nice! I'll have to try that next time. I just wish it were at the class level instead of the method level.
@Guacamole42
@Guacamole42 5 лет назад
I love your vids Tim! Love them, love them love them.. they are teaching me superfast as no book could ever do to me. I get the advanced topics because you are a great and very experienced teacher with many insightfull hints and tips!! (enough with the praises :)) I would love to see a video on topics about, 'So I made an mvc website and how do I publish it'. What do you need from your hostingprovider, which files to transfer etc etc. The pitfalls and perils of publishing an mvc site with database, the whole shebang.
@IAmTimCorey
@IAmTimCorey 5 лет назад
I will add it to the list. Thanks for the suggestion.
@fitzwilliamdarcy3328
@fitzwilliamdarcy3328 2 года назад
Hey Tim, Thanks for the great videos. Just a shortcut to move lines up and down, and you did the swap of rows near1:00:00 for RemoveSelectedRole(), you could simply do Alt up-arrow to swap up, and Alt down-arrow to swap down. Cheers
@tomthelestaff-iamtimcorey7597
@tomthelestaff-iamtimcorey7597 2 года назад
Thanks for the tip!
@stinefelt
@stinefelt 4 года назад
OH my roles lol, fantastic overview and thank you.
@IAmTimCorey
@IAmTimCorey 4 года назад
Thanks
@attofemtopico
@attofemtopico 4 года назад
Hi, Tim Thanks for this excellent tutorial. Regarding to the naming convention, I noticed that in the SellsView, the selected item in Cart was set as SelectedItem="{Binding SelectedCartItem}, and Cart ListBox was named as "Cart". So for the UserRoles ListBox, I used SelectedItem="{Binding SelectedUserRolesItem}, it still worked. we don't need to change to SelectedUserRole. Best reards
@IAmTimCorey
@IAmTimCorey 4 года назад
That works. For me, it is that things in the cart are items while roles are not items. That is why I made the names different.
@roycelithgo3968
@roycelithgo3968 4 года назад
Aren't you supposed to bind the SelectedItem property for ? As in: That fixed the null issue for me and you did it that way on SalesView eg.
@IAmTimCorey
@IAmTimCorey 4 года назад
I don't remember why I did it that way in the SalesView (I assume I had a reason) but with Caliburn Micro, you can use just the name and bind it. You don't need to do the manual binding.
@channing9705
@channing9705 4 года назад
@@IAmTimCorey By testing, I think the prebuild binding rule for selected item is "{Name}s" --> "Selected{Name}". The manual binding is for customized naming :)
@xaviers4105
@xaviers4105 4 года назад
Hi Tim, did you know that when you copy code-lines they are all stored in a clipboard ring? When you want to paste one of these lines you can use Ctrl+Shift+V and then select one of the lines you copied before. So you don't need the notepad anymore. :-)
@IAmTimCorey
@IAmTimCorey 4 года назад
I did and that's a nice feature. I also use Win+V to use the Windows clipboard ring but I'm cautious not to use either on camera since I also copy passwords and other sensitive pieces of data and I don't want them showing up on video.
@bberrevoets
@bberrevoets 3 года назад
Hello Tim, You can use the following in a property to call a async method. LoadRoles().GetAwaiter(); This is working great.
@erikvolger5631
@erikvolger5631 3 года назад
The LoadRoles method doesn't need to be async! You can load the roles in the OnViewLoaded event and cache them. You don't need to read them every time when editing users and roles.
@bberrevoets
@bberrevoets 3 года назад
@@erikvolger5631 Yes, you are right. I just pointed to this because in the video there was a little confusion how to do this, so i say .GetAwaiter(); Thats all.
@Mfolmer
@Mfolmer 4 года назад
Hi Tim! First of all I really enjoy your content (not only this series but your content in generel). The quality of your videos is beyond comparison and your teaching style is absolutely excellent (many university professors could learn a great big deal from you) . Out of curiosity why did you use 'SelectedUserRoles.IndexOf(role.Value) < 0' at 51:41 and not the 'Contains' method? To me it would seem more intuitive to read the if statement with 'Contains'. Is there any specific reason for your choosing?
@IAmTimCorey
@IAmTimCorey 4 года назад
Habit really. Not really another reason. Contains does read a bit nicer.
@channing9705
@channing9705 4 года назад
I found an interesting (should be pre-built) feature in this video 1:00:00. The Remove function will call setter of selectedItem with value null, thus we should call Add before Remove to avoid add a "null" :D
@IAmTimCorey
@IAmTimCorey 4 года назад
Thanks for the tip!
@nbdevito
@nbdevito 4 года назад
Awesome video series. Working my way through. I am having trouble with adding and removing roles. Putting a break point in the Api UserController I see it executing the AddToRole and RemoveFromRole methods with the expected parameters, but when I check my EFData tables, no changes are made to the roles. Any suggestions?
@IAmTimCorey
@IAmTimCorey 4 года назад
Not sure. Something has to be different. Maybe it is making the changes but not committing them?
@nbdevito
@nbdevito 4 года назад
@@IAmTimCorey Thanks you for the advice. Using that I found a suggestion on stackoverflow to add the context.SaveChanges() method after making the changes and it works as expected!
@Nnjaaaaaaa
@Nnjaaaaaaa 5 лет назад
Great video! Can you make a video on how to properly review an existing system please? It will help us beginners a lot!
@IAmTimCorey
@IAmTimCorey 5 лет назад
I will add it to the list. Thanks for the suggestion.
@farsidesc4044
@farsidesc4044 5 лет назад
OG Tim back with more fire!
@IAmTimCorey
@IAmTimCorey 5 лет назад
Thanks!
@mohamedazzouz6086
@mohamedazzouz6086 9 месяцев назад
hello Sir ; On what layer should password hashing and/or encryption take place. ( business layer or data Access layer in C# Windows Forms) Thank you
@njoeror
@njoeror Год назад
Thanks for your great vids Tim. What architecture would you say this is? 5-tier architecture? In that case what does the Business Layer correspond to ?
@IAmTimCorey
@IAmTimCorey Год назад
It is roughly 3-tier, but it doesn't really fit into any neat box. That's the nature of software development - we create these clean diagrams of architecture, but that's not how the real world works.
@defiledgamingnl2284
@defiledgamingnl2284 2 года назад
for some reason i could not just do SelectedItem="SelectedUser" i had to add {Binding SelectedUser} Maybe i have done something wrong? eitherway using Binding SelectedUser works fine.
@janne_kekalainen
@janne_kekalainen 4 года назад
About the non-awaited call, How about calling NotifyOfProperyChange at the end of the load method. The end result is that the role list gets populated nonetheless. (In a worst-case scenario, it might happen with a delay.)
@IAmTimCorey
@IAmTimCorey 4 года назад
Not sure where you are referring to, sorry.
@janne_kekalainen
@janne_kekalainen 4 года назад
@@IAmTimCorey @53:00 The Calling of async LoadRoles() without awaiting. You said that you are not quite happy with it. What I'm saying is that it doesn't really matter if it's awaited or not.
@Roonsine
@Roonsine 3 года назад
so my LoadRoles isn't activatating properly, I think it's because it's an async call, and I'm not awaitng it in the property like you had said early on in the video. I was just wondering if it is because I'm not calling an await (which I can't do in a propfull) Thank you Tim for the hard work on this project. I'm using this project to help me learn and get a job in the IT department of my work. They already have a program they use but it's shitty and they want to replace it.
@Roonsine
@Roonsine 3 года назад
Strange, so my code works, but it won't show the Manager Role, but if I remove the roles currently added I can re-add them back on... so Manager won't load from the Database, but the Cashier and Admin Roles will populate if removed from the user. I still think it's an await error?? because I'm updating the roles after the fact while everything is running it's allowing it to populate the list, but the Manager role will never be populated because it's not reaching that far due to await/async?
@Roonsine
@Roonsine 3 года назад
And then doing more testing lmfao, I hand populated the DB to give myself the Manager role and when I remove it I can re-add it, but for example, I ran my application, removed the Manager role from myself, closed the application and re-ran it. Doing so I only had Cashier and Admin roles which is fine, that works thats what I was hoping would happen, but again the Manager role disappears again like aforementioned.
@erikvolger5631
@erikvolger5631 3 года назад
When moving roles from list to combobox make sure you Add first, because the selectedItem changes...
@mohamaddjelouah9332
@mohamaddjelouah9332 5 лет назад
Thank you
@IAmTimCorey
@IAmTimCorey 5 лет назад
You are welcome.
@jakobhendrix1753
@jakobhendrix1753 4 года назад
A bug I noticed (at least with my version). If you attempt to to access "Users" without first logging in, you will be rejected due to lacking authentication. But then, there is no way to log back in, since I'm left with a blank screen and the menu options for "File" and "Users" I fixed this on the ShellView by making the Account menu item always visible, and added a new Sign In option that was always present. I moved the collapse check to the Sign Out option only.
@IAmTimCorey
@IAmTimCorey 4 года назад
Thanks for sharing. I added this to the Work Item list (#25).
@deekusnotes3318
@deekusnotes3318 Год назад
Hello Tim! Thanks for the video. Everything was working fine as of now. But AddRole method started failing throwing the exception "Not found". Same method works fine from Swagger!! but not through code.
@IAmTimCorey
@IAmTimCorey Год назад
Time to do some debugging. My guess is that it is something little. Maybe a typo.
@deekusnotes3318
@deekusnotes3318 Год назад
@@IAmTimCorey I fixed it. UserRolePairModel was not used as parameter in controller.
@hamidrezaashkiyan
@hamidrezaashkiyan 5 лет назад
Hi and thanks for this great course. Please Add lesson number to title like your previous course.
@IAmTimCorey
@IAmTimCorey 5 лет назад
There is a playlist for this course and they are numbered (the playlist numbers them).
@hamidrezaashkiyan
@hamidrezaashkiyan 5 лет назад
@@IAmTimCorey Oh That's right.
@gallergur
@gallergur 5 лет назад
Do you plan to add a caching mechanism for the WebApi? Would be nice to learn some best practices for memory caching
@IAmTimCorey
@IAmTimCorey 5 лет назад
I can add that to the suggestion list.
@user-rp9iis1en6h
@user-rp9iis1en6h Год назад
What if you want to set the authorization role dynamically? If the system role is configurable than you can't use hard coded Authorize(Role="roleName") .
@IAmTimCorey
@IAmTimCorey Год назад
You can't use dynamic roles with that statement. You would need to do it a different way. However, using a static role is extremely common. In fact, it is the same pattern we see in servers like Exchange Server and others. You assign a role to a task and then you put people into that role or remove them from that role. That's where the dynamic security comes in. People take on roles. We don't typically re-assign roles to tasks.
@user-rp9iis1en6h
@user-rp9iis1en6h Год назад
@@IAmTimCorey Thanks. I know its very common. I just want to know how people handle such scenarios where role is configured dynamically and you want to build a role based approval tree that will allow to configure dynamically.
@canoKes
@canoKes 3 года назад
Is it better to do the role changes locally? If the work is done, you can post it to the api. Thats a serious question :D
@IAmTimCorey
@IAmTimCorey 3 года назад
No, I don't see a benefit to doing it locally.
@dimasprasetya9267
@dimasprasetya9267 4 года назад
Hi Tim, I am so happy cause I have been following this tutorial untill this video. As you say, we are going to move to .NET core in the next video. But, I do not have any basic skills in .NET core. Is it ok if I continue? or I should learn the basic first?
@IAmTimCorey
@IAmTimCorey 4 года назад
Go ahead and continue. I think you will be fine. If not, pause and learn what you need to in order to continue.
@theguire
@theguire 4 года назад
Thanks for solution folder organization.
@IAmTimCorey
@IAmTimCorey 4 года назад
You are welcome.
@santiagopiaggio2099
@santiagopiaggio2099 5 лет назад
Hi tim! Thanks for the videos, i'm looking forward for the big upgrade on Nov 4th! I have one question. If i want to add another user ( just email, first name, last name), i had to add it directly to my sql database on "TRMData" -> "Tables" -> "dbo.User" or i can create an account on swagger? Maybe it's a different answer or none haha. Will the upgrade on .core have a menu option to create users?
@IAmTimCorey
@IAmTimCorey 5 лет назад
You can add the user through Swagger. We need to create a UI for it as well.
@sebastiandhom7172
@sebastiandhom7172 3 года назад
Hi Tim! Its me again ;-) Spent som time searching for an error in my typo. I named the combobox "AvaliableRoles" therefore CM was not able to bind to this control. However: If I would have used listitems="{Binding avaliableRoles}" instead of the implicit "by naming convention" binding, Visual Studio would have told me about it in the XAML Binding errors window.... Is there a way to get those binding errors by wrong type resolved even if you use CM? I could not find anything about that. Do you know a workaround? But maybe there is no need for it sincs CM is no longer supported ;-( Regards, Sebastian
@IAmTimCorey
@IAmTimCorey 3 года назад
That is the downside of convention-based binding. I don't know of an easy way to get those errors, since they aren't really set up for binding. Otherwise, you would get an error if you named a control but didn't have a property/method named that as well.
@nielserikmeier9721
@nielserikmeier9721 3 года назад
I got the listbox SelectItem to work without renameing, as in SalesView just add a Binding
@IAmTimCorey
@IAmTimCorey 3 года назад
Yes, you can do manual binding instead of named binding.
@CoderboyPB
@CoderboyPB 4 года назад
Could you please make a video fixing the issue that the listbox isn't updating the roles? I've tried for hours, but didn't come to a solution ...
@IAmTimCorey
@IAmTimCorey 4 года назад
Noted and added to the list for possible future topics
@CoderboyPB
@CoderboyPB 4 года назад
@@IAmTimCorey Hi Tim, meanwhile I have found a solution, I missed PropertyChanged Event, because I forgot, that the IBindingList get notified about changing the references of the content, but not the properties themselve. I have created a UserDisplayModel, so that I even could clean the UserModel. Here you can see the Models and how I convert them in LoadUsers(). github.com/CoderboyPB/Pocher/blob/master/foo.cs
@CoderboyPB
@CoderboyPB 4 года назад
btw. changing to ObservableCollection was just a move in trying to find the error.
@efimov90
@efimov90 4 года назад
46:27 you can use value.Roles.Values.ToList() instead of value.Roles.Select(x => x.Value).ToList(), is there some reason to do it via lambda?
@IAmTimCorey
@IAmTimCorey 4 года назад
I don't believe so.
@efimov90
@efimov90 4 года назад
@@IAmTimCorey but it works, i have both version of this expression, and right now version with lambda is commented. You can rollback to this video commit and make this change and you see no difference in work of application.
@shilpav44
@shilpav44 5 лет назад
Hi Tim I love your videos. I am one of your big fan. I need your help in one of the topic can you please please help me .I was trying to unit test one of my methods and it had dynamic parameters of dapper I could not find how to mock it. can you please make a video on how to unit test them. I had to change the whole flow because of that which other wise I would have had very generic method in Data access layer.
@IAmTimCorey
@IAmTimCorey 5 лет назад
I will add it to the list. Thanks for the suggestion.
@williamdelmore3005
@williamdelmore3005 4 года назад
Tim, Do you have to save the user permissions in a database? I am trying to add permissions but when i try to create roles and add them it doesnt work. Code: //This Creates the role administrator and adds the user to this role Roles.CreateRole("Administrator"); Roles.AddUserToRole($"{aunthenticatedemployeeid}", "Administrator"); Do you any idea on this and why you cant set a role in code? Also if a database is needed then how does it pass the user and permissions around?
@IAmTimCorey
@IAmTimCorey 4 года назад
You can set this in code and I do cover doing that at some point. As for passing it around, I'm not sure I am understand what you are asking. We will cover using permissions more in the future, including showing how to limit access based upon roles. Maybe that will help.
@williamdelmore3005
@williamdelmore3005 4 года назад
IAmTimCorey by passing it around i mean passing it similar to a method signature. For example i have two methods in my controller if i set the user permissions in code with out saving to a database i would theoretically have to pass the permissions around to each method i want the user to have access too. I was reading more and think maybe adding permissions in the cookie instead but dont know if thats the best practice. The code i posted wont allow me to create a role and thats what’s annoying. Do you have a video on how to set up your webconfig to set user permissions and if you want to allow a user to connect to multiple dbs. My issue is i have 5 different databases im interfacing with and need to set permissions to allow all users to do crud operations but just restrict the visibility of certain pages with out saving permissions i mean i know i can create a permissions table but i just fell that might be more overhead then needed do you have any thoughts on this? Thanks 😊
@tausifkaratela8055
@tausifkaratela8055 2 года назад
when i am trying to log in to wpf it says "an error has occurred while trying to send request". i been trying to solve it since a month. anyone?
@IAmTimCorey
@IAmTimCorey 2 года назад
Did you check to be sure you are doing a Post and that you are sending the bearer token with the word bearer in front?
@tausifkaratela8055
@tausifkaratela8055 2 года назад
@@IAmTimCorey i did. That wasn't the problem. I made a mistake in the database now it's fixed. Thanks bro. Great series 😁
@tomc2745
@tomc2745 3 года назад
Tim, how do you propose we authorize users at an enterprise level where a pool of roles may be assigned uniquely across many offices, customers, projects, and more. I've struggled with this problem for years now and I am curious if you have a design for this situation. Example: Roles = Engineer, Engineering Manager, Sales Associate, Sales Manager Offices = San Francisco, New York, Texas Customers = Customer1, Customer2, Customer3 How can I explicitly assign users to these roles in a intuitive and configurable way?
@tomthelestaff-iamtimcorey7597
@tomthelestaff-iamtimcorey7597 3 года назад
Thank you for raising this complex issue. I have added this to Tim's list of possible future topics.
@ivandrofly
@ivandrofly 5 лет назад
thanks
@IAmTimCorey
@IAmTimCorey 5 лет назад
You are welcome.
@ckbseng
@ckbseng 5 лет назад
first person??
@IAmTimCorey
@IAmTimCorey 5 лет назад
First person for what?
@KrisBunda
@KrisBunda 3 года назад
Great video, Tim! Did you make a follow-up yet where you explain how to get it to refresh and remove the role (Manager) from the left pane display that you just removed using the controls? @1:10:25 I'm having this same situation in an ASP.NET Core app using Identity and have a UI to add new Claims to Users, and I have to logout/login to see those additions/deletions of a Claim to a User in a "User Details" table in the UI--is this an Identity thing?
@yyzhang1260
@yyzhang1260 5 лет назад
thank you
@IAmTimCorey
@IAmTimCorey 5 лет назад
You are welcome.
Далее
ЭТО НАСТОЯЩАЯ МАГИЯ😬😬😬
00:19
Adding Roles to the API - A TimCo Retail Manager Video
36:44
Getting User Data - A TimCo Retail Manager Video
1:13:38