|
|
|
|
@ -130,22 +130,28 @@ define(['underscore', 'text!partials/settings.html'], function(_, template) {
@@ -130,22 +130,28 @@ define(['underscore', 'text!partials/settings.html'], function(_, template) {
|
|
|
|
|
|
|
|
|
|
$scope.registerUserid = function(btn) { |
|
|
|
|
|
|
|
|
|
var successHandler = function(data) { |
|
|
|
|
console.info("Created new userid:", data.userid); |
|
|
|
|
// If the server provided us a nonce, we can do everthing on our own.
|
|
|
|
|
mediaStream.users.store(data); |
|
|
|
|
$scope.loadedUserlogin = true; |
|
|
|
|
safeApply($scope); |
|
|
|
|
// Directly authenticate ourselves with the provided nonce.
|
|
|
|
|
mediaStream.api.requestAuthentication(data.userid, data.nonce); |
|
|
|
|
delete data.nonce; |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
console.log("No userid - creating one ..."); |
|
|
|
|
mediaStream.users.register(btn.form, function(data) { |
|
|
|
|
console.info("Created new userid:", data.userid); |
|
|
|
|
if (data.nonce) { |
|
|
|
|
// If the server provided us a nonce, we can do everthing on our own.
|
|
|
|
|
mediaStream.users.store(data); |
|
|
|
|
$scope.loadedUserlogin = true; |
|
|
|
|
safeApply($scope); |
|
|
|
|
// Directly authenticate ourselves with the provided nonce.
|
|
|
|
|
mediaStream.api.requestAuthentication(data.userid, data.nonce); |
|
|
|
|
delete data.nonce; |
|
|
|
|
successHandler(data); |
|
|
|
|
} else { |
|
|
|
|
// No nonce received. So this means something we cannot do on our own.
|
|
|
|
|
// Make are GET request and retrieve nonce that way and let the
|
|
|
|
|
// Make are GET request and retrieve nonce that way and let the
|
|
|
|
|
// browser/server do the rest.
|
|
|
|
|
// TODO(longsleep): Implement me.
|
|
|
|
|
mediaStream.users.authorize(data, successHandler, function(data, status) { |
|
|
|
|
console.error("Failed to get nonce after create", status, data); |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
}, function(data, status) { |
|
|
|
|
console.error("Failed to create userid", status, data); |
|
|
|
|
|