cancel
Showing results for 
Search instead for 
Did you mean: 

(Solved) userid = email address

michaelc
Champ on-the-rise
Champ on-the-rise
I expect someone has done this, just not me.
I want to change the invite external users to create the user id as there email vs. creating the user id as firstname_lastname.

I followed the code and found in alfresco\web-inf\classes\alfresco\templates\webscripts\org\alfresco\respository\site\invation\invation.post.json.js the following code
         var inviteeFirstName = json.get("inviteeFirstName")  ;
         var inviteeLastName = json.get("inviteeLastName") ;
         var inviteeEmail = json.get("inviteeEmail") ;
         invitation = site.inviteNominated(inviteeFirstName, inviteeLastName, inviteeEmail, inviteeRoleName, acceptUrl, rejectUrl);

  but I don't know where this code is.

  I tried to set it in the frontend javascript module  invationlist.js, it created the user but the email didn't happen.

  anyone have a pointer for me ?
9 REPLIES 9

afaust
Legendary Innovator
Legendary Innovator
Hello,

what you are looking for is a custom UserNameGenerator.

You can create your own generator implementation in Java by implementing the interface UserNameGenerator, and create your specific user name format when inviting external users. The generator in use is configured in authentication-services-context.xml - simply override the userNameGenerator bean in your custom Spring configuration file.

Alternatively, you can adapt the name pattern of the nameBasedUserNameGenerator bean - that way you don't need to implement a Java class.

Regards
Axel

firetux
Champ in-the-making
Champ in-the-making
Hi Axel,
we've migrated from 4.2.f to 5.0.c.
In 4.2.f we implemented this solution. Is this solution in 5.0.c also working? They changed the configration to *.jar during maven.

Best regards
Philipp

Hallo Axel,
wir haben kürzlich von 4.2.f auf 5.0.c migriert. In 4.2.f habe ich username=email genau mit dieser Lösung hier eforlgreich einrichten können.
Nach der Migration zu 5.0.c geht dies nun nicht mehr, ich denke das liegt an der Änderung mit den Konfigrationen richtung jar dateien wegen maven.

Kann ich das einfach so in der 5.0.c so nachbauen, oder sollte man diese Anforderung in 5.0.c anders lösen?

Schöne Grüße
Philipp

afaust
Legendary Innovator
Legendary Innovator
Hello,

moving configuration into the *.jar for Alfresco 5 is just a packaging change. The approach for providing a custom user name generator via a custom Spring file / override in /shared/classes/extension/ should be unaffected by this. There may have been some semantic changes in the configuration other than its packaging that are at fault here - but at the moment I can't see anything that should interfere (looking at my local source clone of Enterprise Edition 5.0 and Community 5.0.c).
What is the behaviour you experience? Are there any log Messages in alfresco.log? Or is it just silently failing?

Regards
Axel

firetux
Champ in-the-making
Champ in-the-making
Hello,

After copy my old (4.2.f) /WEB-INF/classes/alfresco/authentication-services-context.xml to 5.0.c in the same path, i get a lot of exceptions in catalina.out:

I'll post them to paste.bin

http://pastebin.com/Ktk7Kwyu


The "nameBasedUserNameGenerator" Bean can be found here:

http://pastebin.com/VW1E8L0z

Thanks you

Regards
Philipp

afaust
Legendary Innovator
Legendary Innovator
Hello,

You should not modify *-context.xml within WEB-INF Folder - all customizations should only be made in *-context.xml in /shared/classes/alfresco/extension and those files should only contain the changed bean, e.g. should not be a full copy of the authentication-services-context.xml.
The errors you are encountering are because Alfresco has introduced changes in the authentication-services-context.xml which you are overriding fully with config that may no longer be supported in its entirety (classes may have moved / been renamed).
It also appears you have other modified *-context.xml in the WEB-INF directory, e.g. the web-client-application-context.xml which is actually causing the error.

Eliminate everything but the userNameGenerator from your file and move it into extension directory. Also eliminate / move any other configuration files into extension and remove everything except your actual changes from their Contents.

Regards
Axel

firetux
Champ in-the-making
Champ in-the-making
thank you for your answer. Now I understand many of my problems 😉

I've deleted the file in the WEB-INF folder and created a new authentication-services-context.xml in /opt/alfresco/tomcat/shared/classes/alfresco/extension

It contains only the "nameBasedUserNameGenerator" and "passwordGenerator" Bean:



       <bean id="nameBasedUserNameGenerator"
                class="org.alfresco.repo.security.authentication.NameBasedUserNameGenerator">
                <!– name patterns available: %lastName%, lower case last name %firstName%,
                        lower case first name %emailAddress% email address %i% lower case first name
                        inital –>
                <property name="namePattern">
                        <value>%emailAddress%</value>
                </property>

                <property name="userNameLength">
                        <value>30</value>
                </property>
        </bean>

        <!– Used for generating passwords –>
        <bean id="passwordGenerator"
                class="org.alfresco.repo.security.authentication.BasicPasswordGenerator">
                <property name="passwordLength">
                         <value>12</value>
                </property>
        </bean>



But now I get these Exceptions in catalina.out:

http://pastebin.com/LLZPTR7W

The web-client-application-context.xml in /opt/alfresco-5.0.c/tomcat/webapps/alfresco/WEB-INF/classes/alfresco/ cames with the installerscript and I've done no changes in this file.

Do you know why the exceptions (pastbin link) occour?

Thanks for your help

Regards
Philipp

firetux
Champ in-the-making
Champ in-the-making
Hi Axel,
finally i got this customization working!

Additional to simply copy the bean in /extension I've renamed the file to a custom name!

/opt/alfresco/tomcat/shared/classes/alfresco/extension/my-custom-usernamegenerator-context.xml


<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE beans PUBLIC '-//SPRING//DTD BEAN//EN' 'http://www.springframework.org/dtd/spring-beans.dtd'>
<beans>


        <bean id="nameBasedUserNameGenerator"
                class="org.alfresco.repo.security.authentication.NameBasedUserNameGenerator">
                <!– name patterns available: %lastName%, lower case last name %firstName%,
                        lower case first name %emailAddress% email address %i% lower case first name
                        inital –>
                <property name="namePattern">
<!–                    <value>%firstName%_%lastName%</value> –>
                        <value>%emailAddress%</value>
                </property>

                <property name="userNameLength">
                        <value>30</value>
                </property>
        </bean>


        <!– Used for generating passwords –>
        <bean id="passwordGenerator"
                class="org.alfresco.repo.security.authentication.BasicPasswordGenerator">
                <property name="passwordLength">
<!–                    <value>8</value> –>
                         <value>12</value>
                </property>
        </bean>
   </beans>




Now the catalina.out is clean without any exception and the username will be generated as configured.

The only thing to do is to change the email template - but that's another topic

Many thanks for your help!

Regards
Philipp

afaust
Legendary Innovator
Legendary Innovator
Hello,

you only copied left <bean> part in the XML, but the <beans> Header/footer as well as the XML prolog also need to be in there (basic structure of a Spring bean and always implied).

Regards
Axel

michaelc
Champ on-the-rise
Champ on-the-rise
Thanks you gave me the info I needed.
it was even simpler when I looked into the code ( just need to know where to look ) as it was all ready an option.

  name generator is org.alfresco.repo.security.authentication.NameBasedUserNameGenerator
  it has two properties namePattern and userNameLength
    change  namePattern to %emailAddress%
    change userNameLength to 30

  Done.
Getting started

Tags


Find what you came for

We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.