-
Notifications
You must be signed in to change notification settings - Fork 106
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
LSR-931 Expose User object in SessionContext #361
Conversation
👍 LGTM |
👍 |
@@ -72,7 +72,7 @@ public class LoginScreenlet: BaseScreenlet, BasicAuthBasedType { | |||
viewModel.userName = SessionContext.currentContext?.basicAuthUsername | |||
viewModel.password = SessionContext.currentContext?.basicAuthPassword | |||
|
|||
let userAttributes = SessionContext.currentContext!.userAttributes |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a computed property called userAttributes
to maintain backwards compatibility
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 in c5caab8
@@ -48,11 +48,11 @@ public class UpdateCurrentUserLiferayConnector: ServerConnector { | |||
} | |||
|
|||
public func attributeAsString(key: String) -> String { | |||
return SessionContext.currentContext?.userAttribute(key) as! String |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here: add userAttribute(key)
method.
Keep in mind the Liskov Substitution Principle, or as a simple rule of thumb: don't chain more than one period in an expression (don't access one object internals, just ask the object to do something)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 2799c61
@@ -79,7 +79,7 @@ public class UserPortraitScreenlet: BaseScreenlet { | |||
} | |||
|
|||
public func loadLoggedUserPortrait() -> Bool { | |||
guard let userId = SessionContext.currentContext?.userId else { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 in c5caab8
|
||
super.init() | ||
} | ||
|
||
private func int64Value(key: String) -> Int64? { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move these helper methods to somewhere?
No description provided.