Hi Amila,
There are two methods in the manager module,
var getTenantAwareUsername = function (username) {
if(!username){
username = jagg.getUser();
}
var tenantAwareUsername = 'null';
if (username.indexOf("@") != -1) {
tenantAwareUsername = username.substring(0,
username.lastIndexOf('@'));
} else { // else assume super tenant
tenantAwareUsername = SUPER_TENANT_DOMAIN_NAME;
}
return tenantAwareUsername;
};
/*
* getDomainlessUserName is used to get the user name without the domain
name.
*/
var getDomainlessUserName = function (username) {
if(!username){
username = jagg.getUser();
}
var seperator = "@";
var strippedUserName = "";
var index = username.lastIndexOf(seperator);
if (index == -1)
strippedUserName = username;
else
strippedUserName = username.substring(0, index);
return strippedUserName;
};
Thanks,
Asanka D
On Thu, Apr 10, 2014 at 6:17 PM, Amila Maha Arachchi <[email protected]>wrote:
> There should be only one place where the code should refer to get the
> username, tenant domain etc.. If there is no such method available in app
> mgt code, whoever going to fix this, first need to add that method. Then
> when we come across places where we need to change the code, we should
> point to that method.
>
>
> On Thu, Apr 10, 2014 at 4:30 AM, Dimuthu Leelarathne <[email protected]>wrote:
>
>> Hi Amani,
>>
>> Feel free to go ahead and commit the fix in this place and other places
>> that you ran into. If you want us to do a end-to-end test with email as
>> username, we will need a little more time as all of the AF team is
>> sprinting towards the milestone today.
>>
>> thanks,
>> dimuthu
>>
>>
>>
>> On Wed, Apr 9, 2014 at 8:58 PM, Amani Soysa <[email protected]> wrote:
>>
>>> Hi Dilshan
>>>
>>> What I meant is the following
>>>
>>> tenantDomain = userName.substring(userName.lastIndexOf('@') + 1);
>>>
>>> Since we are sure that domain name cannot contain "@" taking lastIndexOf
>>> is enough and safe rather than writing a regular expression to get the
>>> tenant domain .. Is there any reason why you suggested regular expression?
>>>
>>>
>>>
>>>
>>>
>>> On Wed, Apr 9, 2014 at 4:13 PM, Dilshan Edirisuriya <[email protected]>wrote:
>>>
>>>> Although the lastIndexOf will work properly I suggest you add an
>>>> regular expression so that it will work in any instance to get the domain
>>>> name out of it.
>>>>
>>>>
>>>> On Wed, Apr 9, 2014 at 3:55 PM, Amani Soysa <[email protected]> wrote:
>>>>
>>>>> Hi All,
>>>>>
>>>>> We are changing the current tenant model with a flat hierarchy in the
>>>>> cloud, where we keep the email address as the user name.
>>>>> In this model, the logged in user will be [email protected]@abc.com,
>>>>> where my domain name will be abc.com and user name will be
>>>>> [email protected]
>>>>>
>>>>> This introduce couple of issues in app management app as in the app
>>>>> management we assume that there will be only one "@" sign and we are
>>>>> spiting from "@" sign to get the user name and domain separately.
>>>>>
>>>>> For example [1]
>>>>>
>>>>> var getAllAppsOfUser = function(userName){
>>>>> // jagg.module("permission").checkUserAuthenticated();
>>>>> try {
>>>>> var result;
>>>>> result = getAllApps(userName.split('@')[0]);
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> [1] -
>>>>> https://svn.wso2.org/repos/wso2/scratch/appfactorycc/products/appfactory/1.1.0/modules/jaggery-apps/appmgt/src/modules/application/get/list.jag
>>>>>
>>>>> There are several places like this in app management, how should we
>>>>> handle it? Is it possible to change the app_mgt code to break the user
>>>>> from
>>>>> lastIndexOf('@') instead of using split? and also shall we introduce a new
>>>>> module to get the userName and tenantDomain in a central location so we
>>>>> don't have to do this same logic in several jaggery pages.
>>>>>
>>>>>
>>>>> Regards,
>>>>> Amani
>>>>>
>>>>> --
>>>>> Amani Soysa
>>>>> Senior Software Engineer
>>>>> Mobile: +94772325528
>>>>> WSO2, Inc. | http://wso2.com/
>>>>> Lean . Enterprise . Middleware
>>>>>
>>>>> _______________________________________________
>>>>> Architecture mailing list
>>>>> [email protected]
>>>>> https://mail.wso2.org/cgi-bin/mailman/listinfo/architecture
>>>>>
>>>>>
>>>>
>>>>
>>>> --
>>>> Dilshan Edirisuriya
>>>> Senior Software Engineer - WSO2
>>>> Mob: + 94 777878905
>>>> http://wso2.com/
>>>>
>>>> _______________________________________________
>>>> Architecture mailing list
>>>> [email protected]
>>>> https://mail.wso2.org/cgi-bin/mailman/listinfo/architecture
>>>>
>>>>
>>>
>>>
>>> --
>>> Amani Soysa
>>> Senior Software Engineer
>>> Mobile: +94772325528
>>> WSO2, Inc. | http://wso2.com/
>>> Lean . Enterprise . Middleware
>>>
>>> _______________________________________________
>>> Architecture mailing list
>>> [email protected]
>>> https://mail.wso2.org/cgi-bin/mailman/listinfo/architecture
>>>
>>>
>>
>>
>> --
>> Dimuthu Leelarathne
>> Architect & Product Lead of App Factory
>>
>> WSO2, Inc. (http://wso2.com)
>> email: [email protected]
>> Mobile : 0773661935
>>
>> Lean . Enterprise . Middleware
>>
>> _______________________________________________
>> Architecture mailing list
>> [email protected]
>> https://mail.wso2.org/cgi-bin/mailman/listinfo/architecture
>>
>>
>
>
> --
> *Amila Maharachchi*
> Senior Technical Lead
> WSO2, Inc.; http://wso2.com
>
> Blog: http://maharachchi.blogspot.com
> Mobile: +94719371446
>
>
> _______________________________________________
> Architecture mailing list
> [email protected]
> https://mail.wso2.org/cgi-bin/mailman/listinfo/architecture
>
>
--
*Asanka DissanayakeSoftware Engineer*
*WSO2 Inc. - lean . enterprise . middleware | wso2.com <http://wso2.com/>*
*email: [email protected] <[email protected]>, blog:
cyberwaadiya.blogspot.com
<http://cyberwaadiya.blogspot.com>, asankastechtalks.wordpress.com
<http://asankastechtalks.wordpress.com> mobile: +94 71 8373821*
_______________________________________________
Architecture mailing list
[email protected]
https://mail.wso2.org/cgi-bin/mailman/listinfo/architecture