Skip to content

Commit

Permalink
Add registration page.
Browse files Browse the repository at this point in the history
  • Loading branch information
François Prunayre committed Oct 10, 2013
1 parent ab86971 commit 09dba2f
Show file tree
Hide file tree
Showing 19 changed files with 315 additions and 35 deletions.
11 changes: 5 additions & 6 deletions web-ui/src/main/resources/catalog/js/GnLoginModule.js
@@ -1,13 +1,12 @@
(function() {
goog.provide('gn_login');

goog.require('gn');
goog.require('gn_login_controller');


var module = angular.module('gn', [
'pascalprecht.translate',
'gn_translation_controller',
'gn_login_controller',
'gn_cat_controller'
var module = angular.module('gn_login', [
'gn',
'gn_login_controller'
]);

//Define the translation files to load
Expand Down
25 changes: 23 additions & 2 deletions web-ui/src/main/resources/catalog/js/LoginController.js
Expand Up @@ -8,7 +8,28 @@
/**
*
*/
module.controller('GnLoginController', ['$scope', function($scope) {
}]);
module.controller('GnLoginController',
['$scope', '$http', '$rootScope', '$translate',
function($scope, $http,$rootScope, $translate) {

/**
* Register user
*/
$scope.register = function(formId) {
$http.get('create.account@json?' + $(formId).serialize())
.success(function(data) {
$scope.registrationStatus = data;

})
.error(function(data) {

$rootScope.$broadcast('StatusUpdated', {
title: $translate('registrationError'),
error: data,
timeout: 0,
type: 'danger'});
});
};
}]);

})();
2 changes: 1 addition & 1 deletion web-ui/src/main/resources/catalog/lib/closure/deps.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 0 additions & 9 deletions web-ui/src/main/resources/catalog/locales/en-admin.json
Expand Up @@ -159,15 +159,6 @@
"newUser": "New user ",
"userRecords": " records found for ",
"userRecord": " record found for ",
"name": "Name",
"usernameHelp": "Name to use when sign in",
"email": "Email",
"organisation": "Organisation",
"address": "Address",
"zip": "ZIP",
"state": "State",
"city": "City",
"country": "Country",
"isAdministrator": "Is an administrator ?",
"defineUserGroupsPerProfile": "Select user groups per profile",
"passwordRepeat": "Repeat password",
Expand Down
17 changes: 17 additions & 0 deletions web-ui/src/main/resources/catalog/locales/en-core.json
Expand Up @@ -36,6 +36,23 @@
"notifications": "Notifications",
"signout": "Sign out",

"name": "Name",
"surname": "Surname",
"requestedProfile": "Requested profile",
"contactDetailsSentTo": "An email has been sent to ",
"errorEmailAddressAlreadyRegistered": "Email address already registered.",
"newAccountInfo": "When you request an account an email will be sent to you with your user details. If an advanced user profile is requested, the catalog administrator will analyze your request and get back to you.",
"usernameHelp": "Name to use when sign in",
"email": "Email",
"organisation": "Organisation",
"address": "Address",
"zip": "ZIP",
"state": "State",
"city": "City",
"country": "Country",
"register": "Register",


"from": "From",
"to": "To",
"until": "Until",
Expand Down
9 changes: 0 additions & 9 deletions web-ui/src/main/resources/catalog/locales/fr-admin.json
Expand Up @@ -146,15 +146,6 @@
"newUser": "Nouvel utilisateur ",
"userRecords": " fiches trouvées pour ",
"userRecord": " fiche trouvée pour ",
"name": "Nom",
"usernameHelp": "Nom à utiliser pour l'identification.",
"email": "Email",
"organisation": "Organisation",
"address": "Adresse",
"zip": "Code postal",
"state": "Région",
"city": "Ville",
"country": "Pays",
"isAdministrator": "Est administrateur ?",
"defineUserGroupsPerProfile": "Sélectionner pour chaque profil les groupes de l'utilisateur",
"passwordRepeat": "Resaisir le mot de passe",
Expand Down
16 changes: 16 additions & 0 deletions web-ui/src/main/resources/catalog/locales/fr-core.json
Expand Up @@ -38,6 +38,22 @@
"notifications": "Notifications",
"signout": "Se déconnecter",

"name": "Prénom",
"surname": "Nom",
"requestedProfile": "Profil souhaité",
"contactDetailsSentTo": "Un email a été envoyé à l'adresse ",
"errorEmailAddressAlreadyRegistered": "Adresse email déjà enregistrée.",
"newAccountInfo": "Une fois votre demande de création de compte faite, un email vous sera envoyé. Si vous demandez un profil utilisateur avancé, l'administrateur du catalogue analysera votre demande et vous fera un retour.",
"usernameHelp": "Nom à utiliser pour l'identification.",
"email": "Email",
"organisation": "Organisation",
"address": "Adresse",
"zip": "Code postal",
"state": "Région",
"city": "Ville",
"country": "Pays",
"register": "Créer un compte",

"from": "De",
"to": " à ",
"by": "par",
Expand Down
1 change: 1 addition & 0 deletions web-ui/src/main/resources/catalog/style/gn_login.less
@@ -0,0 +1 @@
@import "gn.less";
Expand Up @@ -95,7 +95,7 @@
</div>

<div data-ng-class="userSelected.surname == '' ? 'has-error' : ''">
<label class="control-label" data-translate>username</label>
<label class="control-label" data-translate>surname</label>
<input type="text" name="surname" class="form-control"
data-ng-model="userSelected.surname"></input>
</div>
Expand Down
103 changes: 103 additions & 0 deletions web-ui/src/main/resources/catalog/templates/new-account.html
@@ -0,0 +1,103 @@
<div class="container" data-ng-controller="GnLoginController">
<div class="col-lg-6">
<div class="panel">
<div class="panel-heading" data-translate="">needAnAccount</div>
<form class="form-horizontal" id="userinfo" action="create.account" method="post">

<div class="form-group">
<label class="control-label col-lg-4" data-translate="">email</label>
<div class="col-lg-8">
<input type="email" name="email" autofocus="" class="form-control"/>
</div>
</div>

<div class="form-group">
<label class="control-label col-lg-4" for="inputName" translate="">name</label>
<div class="col-lg-8">
<input type="text" class="form-control" id="inputName" name="name"/>
</div>
</div>

<div class="form-group">
<label class="control-label col-lg-4" for="inputUsername" translate=""
>surname</label>
<div class="col-lg-8">
<input type="text" class="form-control" id="inputUsername" name="surname"/>
</div>
</div>

<div class="form-group">
<label class="control-label col-lg-4" data-translate="">organisation</label>
<div class="col-lg-8">
<!-- TODO : Add org list -->
<input type="text" name="org" class="form-control"/>
</div>
</div>


<fieldset>
<legend data-translate="">address</legend>


<div class="form-group">
<label class="control-label col-lg-4" data-translate="">address</label>
<div class="col-lg-8">
<input type="text" name="address" class="form-control"/>
</div>
</div>
<div class="form-group">
<label class="control-label col-lg-4" data-translate="">zip</label>
<div class="col-lg-8">
<input type="text" name="zip" class="form-control"/>
</div>
</div>
<div class="form-group">
<label class="control-label col-lg-4" data-translate="">state</label>
<div class="col-lg-8">
<input type="text" name="state" class="form-control"/>
</div>
</div>
<div class="form-group">
<label class="control-label col-lg-4" data-translate="">city</label>
<div class="col-lg-8">
<input type="text" name="city" class="form-control"/>
</div>
</div>
<div class="form-group">
<label class="control-label col-lg-4" data-translate="">country</label>
<div class="col-lg-8">
<!-- TODO : Add country list -->
<input type="text" name="country" class="form-control"/>
</div>
</div>
</fieldset>

<div class="form-group">
<label class="control-label col-lg-4" data-translate="">requestedProfile</label>
<div class="col-lg-8">
<select name="profile" class="form-control">
<option data-ng-repeat="p in profiles" value="{{p}}">{{p |
translate}}</option>
</select>
</div>
</div>
</form>
<button data-ng-click="register('#userinfo')" class="btn btn-primary btn-block"
data-translate="">register</button>

<p
data-ng-show="registrationStatus && registrationStatus['result'] != 'errorEmailAddressAlreadyRegistered'">
<span data-translate="">contactDetailsSentTo</span>
<strong>{{registrationStatus['@email']}}</strong>. </p>
<p
data-ng-show="registrationStatus && registrationStatus['result'] == 'errorEmailAddressAlreadyRegistered'">
<span class="text-danger"
data-ng-show="registrationStatus['result'] == 'errorEmailAddressAlreadyRegistered'"
> {{registrationStatus['result'] | translate}} </span>
</p>
</div>
</div>
<div class="col-lg-6">
<p data-translate="">newAccountInfo</p>
</div>
</div>
4 changes: 2 additions & 2 deletions web-ui/src/main/resources/catalog/templates/signin.html
Expand Up @@ -25,11 +25,11 @@
<div class="panel-heading" data-translate>needAnAccount</div>
<p data-translate>needAnAccountInfo</p>
<p>
<button type="submit" class="btn" data-translate>createAnAccount</button>
<a class="btn btn-default" href="new.account" data-translate="">createAnAccount</a>
</p>
</div>
<div class="panel">
<div class="panel-heading" data-translate>forgetDetails</div>
<div class="panel-heading" data-translate="">forgetDetails</div>
<p data-translate>forgetDetailsInfo</p>
<p>

Expand Down
6 changes: 3 additions & 3 deletions web-ui/src/main/resources/catalog/templates/top-toolbar.html
Expand Up @@ -12,9 +12,9 @@
<ul class="nav navbar-nav">
<li data-ng-show="authenticated">
<p class="navbar-text"><img src="http://gravatar.com/avatar/{{user.hash}}?s=18"/>
<a href="#userDetails" title="{{'userDetails' | translate}}" class="navbar-link">
{{user.name}} {{user.surname}} ({{user.profile | translate}})</a>
<a href="#/organization/users/{{user.username}}" title="{{'userPreferences' | translate}}"><i class="icon-user"></i></a>
<a href="admin.console#/organization/users/{{user.username}}"
title="{{'userDetails' | translate}}" class="navbar-link">
{{user.name}} {{user.surname}} ({{user.profile | translate}})<i class="icon-user"></i></a>
<a href="../../j_spring_security_logout" title="{{'signout' | translate}}"><i class="icon-signout"></i></a>
</p>
</li>
Expand Down
3 changes: 3 additions & 0 deletions web/src/main/webapp/WEB-INF/config-security-mapping.xml
Expand Up @@ -516,6 +516,9 @@ xsi:schemaLocation="http://www.springframework.org/schema/beans
<sec:intercept-url pattern="/srv/[a-z]{2,3}/catalog.search.nojs!?.*" access="permitAll"/>
<sec:intercept-url pattern="/srv/[a-z]{2,3}/catalog.signin!?.*" access="permitAll"/>

<sec:intercept-url pattern="/srv/[a-z]{2,3}/new.account!?.*" access="permitAll"/>
<sec:intercept-url pattern="/srv/[a-z]{2,3}/create.account!?.*" access="permitAll"/>

<sec:intercept-url pattern="/srv/[a-z]{2,3}/catalog.edit!?.*" access="hasRole('Editor')"/>


Expand Down
Expand Up @@ -3,6 +3,14 @@
<services package="org.fao.geonet">
<documentation>User and group services</documentation>

<service name="create.account">
<documentation><![CDATA[
Create a new user account.
]]></documentation>
<class name=".services.register.SelfRegister" />
<error sheet="../xslt/error/error-json.xsl"/>
</service>

<service name="admin.user.update">
<documentation>The service can be used to create or update
a user.</documentation>
Expand Down
9 changes: 8 additions & 1 deletion web/src/main/webapp/WEB-INF/config/config-ui-admin.xml
Expand Up @@ -11,6 +11,13 @@
<documentation>The user authentication page.</documentation>
<output sheet="../xslt/ui-admin/signin.xsl"/>
</service>


<service name="new.account">
<documentation><![CDATA[
User self-registration services
]]></documentation>
<output sheet="../xslt/ui-admin/new-account.xsl"/>

</service>
</services>
</geonet>
2 changes: 1 addition & 1 deletion web/src/main/webapp/xslt/common/base-variables.xsl
Expand Up @@ -17,7 +17,7 @@
<!-- Define which JS module to load using Closure -->
<xsl:variable name="angularApp" select="
if ($service = 'admin.console') then 'gn_admin'
else if ($service = 'catalog.login') then 'gn_login'
else if ($service = 'catalog.login' or $service = 'new.account') then 'gn_login'
else if ($service = 'catalog.edit') then 'gn_editor'
else 'gn'"/>

Expand Down
@@ -0,0 +1,55 @@
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<!--
Create xml containing profile request email details from user/instance details passed
Allows email to be customised without changing java service - info supplied is as follows
<root>
<site>localtrunk</site>
<siteURL>http://127.0.0.1:8122/geonetwork</siteURL>
<request>
<zip>7001</zip>
<address>University of Tasmania, Hobart</address>
<email>craig.jones@utas.edu.au</email>
<name>Craig</name>
<state>Tas</state>
<surname>Jones</surname>
<org>emii</org>
<kind>uni</kind>
<profile>RegisteredUser</profile>
<country>au</country>
</request>
</root>
-->
<xsl:template match="/">
<email>
<subject>"<xsl:value-of select="/root/request/profile"/>" access for <xsl:value-of select="/root/request/email"/> for <xsl:value-of select="/root/site"/></subject>
<content>Dear Admin,

Newly registered user <xsl:value-of select="/root/request/email"/> has requested "<xsl:value-of select="/root/request/profile"/>" access for:

Instance: <xsl:value-of select="/root/site"/>
Url: <xsl:value-of select="/root/siteURL"/>

User registration details:

Name: <xsl:value-of select="/root/request/name"/>
Surname: <xsl:value-of select="/root/request/surname"/>
Email: <xsl:value-of select="/root/request/email"/>
Organisation: <xsl:value-of select="/root/request/org"/>
Type: <xsl:value-of select="/root/request/kind"/>
Address: <xsl:value-of select="/root/request/address"/>
State: <xsl:value-of select="/root/request/state"/>
Post Code: <xsl:value-of select="/root/request/zip"/>
Country: <xsl:value-of select="/root/request/country"/>

Please action.

<xsl:value-of select="/root/site"/>
</content>
</email>
</xsl:template>

</xsl:stylesheet>

0 comments on commit 09dba2f

Please sign in to comment.