EDIT:

Did you require this for the following scenario:

1. User registers
2. User logs in and receives the subscriber role
3. Admin removes the subscriber role from the user
4. User logs in and receives the subscriber role since he does not have the
role

Is this a valid use case? If not can we not do this with the above
suggestion?


On Mon, Jul 20, 2015 at 12:02 PM, Sameera Medagammaddegedara <
[email protected]> wrote:

> Hi Lakshman,
>
>
> Could we not do this in the onUserLoggedIn callback itself after checking
> if the logged in user already has the subscriber role or not?
>
>
> Thank You,
> Sameera
>
> On Mon, Jul 20, 2015 at 6:10 AM, Lakshman Udayakantha <[email protected]>
> wrote:
>
>> Couldn't add onLogin function is used in extension in previous mail.
>> sorry for that. find it below.
>>
>> onUserLoggedIn : function(){
>>             var userName=ctx.username;
>>             var apistore =
>> require('apistore').apistore.instance(userName);
>>             var subscriber=apistore.getSubscriber(userName);
>>             if(!subscriber){
>>                 apistore.addSubscriber(userName,ctx.tenantId);
>>             }
>>         },
>>
>> additionally, found below function
>>
>>  event.on('userRegister', function (tenantId, user) {
>>         log.info("user registering...................................");
>>         configs(tenantId).userRoles.forEach(function (role) {
>>             if (user.hasRoles([role])) {
>>                 return;
>>             }
>>             user.addRoles([role]);
>>         });
>>     });
>>
>> It should be call on user signup. But it calls on first login for the
>> users who signed up. Any way I can't change that function to add subscriber
>> role to users because this function found in store/module/store.js file
>> which is not in extension directory. simply this function reside in ES code
>> and adding subscriber role to users should happen in extension because that
>> functionality is specific to API store.
>>
>> Thanks
>>
>> On Mon, Jul 20, 2015 at 3:05 PM, Lakshman Udayakantha <[email protected]
>> > wrote:
>>
>>> Hi Sameera/ES Team,
>>>
>>> I am working on [1]. I want to add to users who sign up in store, the
>>> subscriber role.
>>> Below function is used to add users as subscribers in their first login
>>> to subscriber tables in asset.js function in store extension. similar
>>> requirement needs for signup as well. how do I achieve this?
>>>
>>> [1] https://wso2.org/jira/browse/REGISTRY-2683
>>>
>>> Thanks
>>> --
>>> Lakshman Udayakantha
>>> WSO2 Inc. www.wso2.com
>>> lean.enterprise.middleware
>>> Mobile: *0711241005*
>>>
>>>
>>
>>
>> --
>> Lakshman Udayakantha
>> WSO2 Inc. www.wso2.com
>> lean.enterprise.middleware
>> Mobile: *0711241005*
>>
>>
>
>
> --
> Sameera Medagammaddegedara
> Software Engineer
>
> Contact:
> Email: [email protected]
> Mobile: + 94 077 255 3005
>



-- 
Sameera Medagammaddegedara
Software Engineer

Contact:
Email: [email protected]
Mobile: + 94 077 255 3005
_______________________________________________
Dev mailing list
[email protected]
http://wso2.org/cgi-bin/mailman/listinfo/dev

Reply via email to