Welcome Guest, Not a member yet? Register   Sign In
IDEA: Centralized userId
#4

(04-05-2019, 11:33 AM)MGatner Wrote: I'm precisely *not* looking for an authentication library, as well as agreeing that CI shouldn't include one, but rather recommending CI have a standardized means for accessing a user ID or unique identifier that authentication libraries could set and other libraries and code could rely on. The problem as a library developer is that if I don't bundle some authentication within my library (which is a terrible solution) then I can't reliably know if a user is logged in or how to identify that user, because every authentication library out there may have their own way & place to store it. Typically it probably shouldn't be CI's job to 'curate' this kind of info, but "current user" is such a core concept I think it may have a spot.
Store where... Probably as a config value that is set on=the-fly and optionally accessed through a service? just a guess.

It seems to me that your library would depend on access to an instance of whatever authentication class the developer is using. Instances would be passed to your constructors or defined by a setter method in your library. Then you need "callables" to the appropriate methods that would return the item you need - be it logged in status or a user id. I see these as config items - essentially strings that are the names of the appropriate method in the class you're depending on. e.g.
PHP Code:
public $isAuthenticated  'isLoggedIn';
public 
$UID 'getUserID'

This seems to satisfy your need and not require a framework-wide property of debatable value.

Obviously, the third-party authentication library must have - or be extendable enough to allow adding - methods that return values you can use.
Reply


Messages In This Thread
IDEA: Centralized userId - by MGatner - 04-05-2019, 05:03 AM
RE: IDEA: Centralized userId - by albertleao - 04-05-2019, 07:22 AM
RE: IDEA: Centralized userId - by MGatner - 04-05-2019, 11:33 AM
RE: IDEA: Centralized userId - by dave friend - 04-05-2019, 04:00 PM
RE: IDEA: Centralized userId - by MGatner - 04-05-2019, 06:37 PM
RE: IDEA: Centralized userId - by mmx - 01-29-2020, 12:19 AM
RE: IDEA: Centralized userId - by ciadmin - 06-12-2019, 05:47 PM
RE: IDEA: Centralized userId - by MGatner - 06-16-2019, 11:36 AM
RE: IDEA: Centralized userId - by MGatner - 06-17-2019, 06:52 AM
RE: IDEA: Centralized userId - by tony.a - 10-17-2019, 04:01 AM
RE: IDEA: Centralized userId - by AndreiCurelaru - 10-17-2019, 05:08 AM
RE: IDEA: Centralized userId - by InsiteFX - 10-17-2019, 03:53 PM



Theme © iAndrew 2016 - Forum software by © MyBB