U4-11046 - Optimisation - Create standardised and encapsulated way of getting the current logged in users details

Created by Pete Duncanson 03 Mar 2018, 14:16:13 Updated by Niels Hartvig 12 Mar 2018, 10:38:42

Subtask of: U4-11042

A couple of issues need a way to get the current users locale but there is no central re-usable way/place to get this from. Here is how its down for LocalizedText.js (https://github.com/umbraco/Umbraco-CMS/blob/cf86409e3fec4198744189a48255543fc2f32614/src/Umbraco.Web/Editors/BackOfficeController.cs#L159) which is part of U4-11044

Suggest we make one (or someone tell me of an existing way that is already done as I can't find it) which brings the code here:

Into a CurrentUser object of some sort. Ideally other scripts could then use this to keep all this stuff central (such as the avatar image off the top of my head).

The front-end would need this too and this raises some questions. For ease we could just make the new class serialisable and then bolt it onto the existing Umbraco.Sys.ServerVariables global that we generate for all back office users (https://github.com/umbraco/Umbraco-CMS/blob/cf86409e3fec4198744189a48255543fc2f32614/src/Umbraco.Web/Editors/BackOfficeServerVariables.cs) or we could be a little smarter and create a new service that provides this data. Either way we have an issue of keeping the data on the server in sync with the data on the client or when a user changes their language for instance in the back office the front-end will still be running off the old data so we'd need to get that worked out. Suggest looking into if anything else already does this with the existing service and take it from there (in light of the current discussions at http://issues.umbraco.org/issue/U4-11042 we should see if we are happy with the way its currently done and if there are ways we can improve it or just mimic whats there if its awesome and working).

Comments

Pete Duncanson 03 Mar 2018, 14:18:00

We should do this before we do the ones that depend on it


Pete Duncanson 04 Mar 2018, 15:13:29

Found this in the Belle docs:

https://umbraco.github.io/Belle/#/api/umbraco.resources.currentUserResource

Why didn't I find that before! Seems to make sense to add this to that resource. What other data might we want/need to add to there? Seems that avatar pic etc. could/should get its data from this central source.


Priority: Up for grabs

Type: Feature (request)

State: Submitted

Assignee:

Difficulty: Normal

Category: Editor

Backwards Compatible: True

Fix Submitted:

Affected versions:

Due in version:

Sprint:

Story Points:

Cycle: