Skip to content

Commit

Permalink
Improved registration UX and labels. Also, instance name is now retur…
Browse files Browse the repository at this point in the history
…ned after successfull registration to the client. Refers #387, #355.
  • Loading branch information
otsakir committed Aug 19, 2015
1 parent 21216ab commit da39544
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,19 @@
import org.mobicents.servlet.restcomm.identity.KeycloakClient.KeycloakClientException;
import org.mobicents.servlet.restcomm.identity.KeycloakConfigurator.IdentityMode;

import com.google.gson.Gson;

@Path("/instance")
public class IdentityEndpoint extends AbstractEndpoint {

public class IdentityInstanceEntity {
private String instanceName;

public void setInstanceName(String instanceName) {
this.instanceName = instanceName;
}
}

//public static String IDENTITY_PROXY_URL = "https://identity.restcomm.com/instance-manager";
private KeycloakConfigurator keycloakConfigurator;

Expand Down Expand Up @@ -54,7 +64,12 @@ public Response registerInstance(@FormParam("restcommBaseUrl") String baseUrl, @
keycloakConfigurator.updateRestcommXml(); // not effective until i find a way update restcomm.xml or store to database

logger.info( "User '" + username + "' registed this instance as '" + instanceName + "' to authorization server " + authUrl);
return Response.ok().build();

IdentityInstanceEntity instanceEntity = new IdentityInstanceEntity();
instanceEntity.setInstanceName(instanceName);
Gson gson = new Gson();

return Response.ok().entity(gson.toJson(instanceEntity)).build();
}

// generate a random secret for the instance/restcomm-rest client if none specified in the request
Expand Down

This file was deleted.

2 changes: 1 addition & 1 deletion restcomm/restcomm.ui/src/main/webapp/modules/register.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<div class="controls">
<div class="input-group col-md-6">
<span ng-show="registerForm.password.$dirty && registerForm.password.$error.required" class="input-group-addon">Password is required</span>
<input type="text" name="password" id="password" class="form-control" ng-model="instance.password" placeholder="Your password" required />
<input type="password" name="password" id="password" class="form-control" ng-model="instance.password" placeholder="Your password" required />
</div>
</div>
</div>
Expand Down
20 changes: 20 additions & 0 deletions restcomm/restcomm.ui/src/main/webapp/modules/unregistered.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<div class="row">
<div class="col-md-6 col-md-offset-3 well well-large" >
<legend>Unregistered instance</legend>

<p>
Your instance is not registered!
</p>
<p>
If you already have a Restcomm account click <a href="#/register">here</a> to quickly register your instance to our identity cloud.
</p>
<p>
If you don't have a Restcomm account, please create one <a href="https://identity.restcomm.com/auth/admin/restcomm/console/" target="_blank">here</a> before proceeding.
</p>
<p>
If you prefer hosting your own identity server you can follow the instructions on our <a>Standalone Restcomm Identity Server guide</a>.
</p>

</div>
</div>
</div>
4 changes: 2 additions & 2 deletions restcomm/restcomm.ui/src/main/webapp/resources/js/restcomm.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@ rcMod.config(['$routeProvider', '$locationProvider', 'authMode', function($route
} else
if (authMode == 'init') {
$routeProvider.
when('/config/unregistered', {templateUrl: 'modules/config-unregistered.html', controller: 'UnregisteredCtrl'}).
when('/unregistered', {templateUrl: 'modules/unregistered.html', controller: 'UnregisteredCtrl'}).
when('/register', {templateUrl: 'modules/register.html', controller: 'RegisterCtrl'}).
otherwise({redirectTo: '/register'});
otherwise({redirectTo: '/unregistered'});
}
}]);

Expand Down
6 changes: 3 additions & 3 deletions restcomm/restcomm.ui/src/main/webapp/resources/js/services.js
Original file line number Diff line number Diff line change
Expand Up @@ -547,7 +547,7 @@ rcServices.factory("InstanceService", function($http) {
var service = {};

service.registerInstance = function(instance) {
console.log("registering instance at " + instance.authUrl);
console.log("registering instance to " + instance.authUrl);
var params = $.param(instance);

$http({
Expand All @@ -556,8 +556,8 @@ rcServices.factory("InstanceService", function($http) {
headers:{'Content-Type': 'application/x-www-form-urlencoded'},
data: params
})
.success(function () {
console.log("succesfully registered instance");
.success(function (data) {
console.log("succesfully registered instance as " + data.instanceName);
})
.error(function () {
console.log("error registering instance");
Expand Down

0 comments on commit da39544

Please sign in to comment.