I have at least one model in my Yii project that will need to reference a particular user ID. In my SQL for the model I have something like CONSTRAINT FOREIGN KEY (user_id) REFERENCES User(id). I was going to go ahead and create a User model when I came across the docs for CUserIdentity. I have to admit I am confused. Is a CUserIdentity a user or a state associated with a particular user-case? I would like to use as much of the built-in Yii features as possible since they handle a lot of security-related issues from what I understand, and I am aware of the existence of some modules like srbac that handle user authentication and registration management. Please guide me in the right direction. (Also at issue: what is the relationship between models and components?)
Yii CUserIdentity vs a User Model
2.5k Views Asked by tacos_tacos_tacos At
1
There are 1 best solutions below
Related Questions in PHP
- php Variable name must change in for loop
- register_shutdown_function is not getting called
- Query returning zero rows despite entries existing
- Retrieving *number* pages by page id
- Automatically closing tags in form input?
- How to resize images with PHP PARSE SDK
- how to send email from localhost using codeigniter?
- Mariadb max Error while sending QUERY packet PID
- Multiusers login redirect different page in php
- Imaginary folder when I use "DirectoryIterator" in PHP?
- CodeIgniter + XDebug: debug only working in the main controller, index() function
- PHP script timeout when I use sleep()
- posting javascript populated form to another php page
- AJAX PHP - Reload div after submit
- PHP : How can I check Array in array?
Related Questions in OOP
- Access objects variable & method by name
- Why does compiler recognize while(true) at compile time but not if(true)
- Pass variables to extended class
- Cast a superclass type to a subclass type?
- Understanding difference in Swift properties for structs and classes in assignment
- Does exist any way to force child class to have at least one field with a specified attribute?
- Symfony : is it better to use a trait or an intermediary class to complete Controller one?
- (Java) What kind of argument is this? With a
- C++ Implementing a Queue of cars in OOP
- Inheritance in openERP (odoo)
- missing 1 required positional argument: 'key'
- how can Object class in ruby be an instance of it's subclass, class "Class"
- How to force others to obey a specific layout for a child class?
- Class variables in OOP
- define_method in a class method
Related Questions in YII
- An error comes in the code while using HybridAuth as extension in yii framework-"undefined variable-user_profile"
- yii 2 pagination is losing filter data in the model
- CJuiDatePicker not saving date in db
- PHP YII2 set session group_concat_max_len
- Error 500 Creating default object from empty value when uploading a file
- Yii, Load a model of a module from the main app controller
- Yii phpunit error SeleniumTestCase.php fail to open stream
- Yii will not move_uploaded_file - 500 internal server error
- Ajax Request is Not Working After CGridView Update
- Facebook SDK PHP
- Pagination in Yii framework doesn't work correctly
- Update record without replacing file path in Yii
- Yii 1.1 - Many to Many Relationship - Returning data from relation table
- Yii2 file upload is not validating file type
- Automagically logout user after session expires
Related Questions in YII-COMPONENTS
- Yii swift mailer not sending mail
- publish_actions scope is not working for the created app in facebook
- How to show the particular role users in dropdown using yii2?
- How to add custom link in Yii 2 validation error message?
- How to get last insert record - Yii 2
- Cannot do filtering via a dropdown menu in Yii TbGridView (v1.x.x)
- Bulk deletion using checkboxes in yii Cgridview
- Yii2 Advanced Template Customization
- I have created a module using gii in yii2 , declared that in yii console.php in config , still can't access by index.php/moduleid
- Detail documentation to implement Role based access control in yii from initial?
- Check existence of a relation in a model
- Yii Rights :: Error 403 You Are Not Authorized To Perform This Action
- How to load Yii modules component?
- Customised query to display in CGridView in yii
- How To Count Views On Click Of A Button Or Web Page Is There Any Extension
Related Questions in YII-INHERITANCE
- How to reuse Yii form using scenario
- Implementing Yii RESTful API from example - _sendResponse function generating 500 error
- How To wigetized a single view using several models in Yii?
- Yii2-Api: How to pass Token for the HttpBearer Filter
- How to load selected list items in multiple-select-listbox in update view in yii?
- Yii CUserIdentity vs a User Model
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
First off, do go ahead and create a
Usermodel, you will need it.With that out of the way:
CUserIdentityrepresents the concept of "who the user is", while theUsermodel represents "information about a user of my application".CUserIdentityis applicable in all cases where there is more than one kind of user (i.e. guest), while theUsermodel is only applicable when you are storing information about the users yourself. Admittedly, in most cases both will be applicable and this is what creates the confusion.Usually, the relation between the two is that
CUserIdentity, in order to answer questions such as "who the user is", "is the user allowed to access this resource" etc. queries theUsermodel from the database to get the information it needs to answer these questions. This relationship between the two concepts is also documented in the definitive guide to Yii. After e.g. authenticating the user, it would expose some or all of the information on theUsermodel through its own properties (which you would have to define).To give an example of a scenario where there would be no
Usermodel, think about a website that lets you log in using your LDAP user account. When theCUserIdentity::authenticatemethod is called, the component would authenticate the credentials against the LDAP server and after a successful authentication would again grab any other relevant information and expose it through its own properties.