Generate and submit registrationId, fixes #25
If we're expecting to get registrationIds from others, it's only fair that we also supply our own.
This commit is contained in:
parent
5752a772d1
commit
e3b00e08f3
2 changed files with 7 additions and 4 deletions
|
@ -103,7 +103,7 @@ var API = new function() {
|
|||
};
|
||||
|
||||
this.confirmCode = function(code, number, password,
|
||||
signaling_key, single_device,
|
||||
signaling_key, registrationId, single_device,
|
||||
success_callback, error_callback) {
|
||||
var call = single_device ? 'accounts' : 'devices';
|
||||
var urlPrefix = single_device ? '/code/' : '/';
|
||||
|
@ -115,8 +115,9 @@ var API = new function() {
|
|||
user : number,
|
||||
password : password,
|
||||
jsonData : { signalingKey : btoa(getString(signaling_key)),
|
||||
supportsSms : false,
|
||||
fetchesMessages : true },
|
||||
supportsSms : false,
|
||||
fetchesMessages : true,
|
||||
registrationId: registrationId},
|
||||
}).then(function(response) {
|
||||
if (success_callback !== undefined)
|
||||
success_callback(response);
|
||||
|
|
|
@ -41,6 +41,8 @@ var single_device = false;
|
|||
var signaling_key = window.crypto.getRandomBytes(32 + 20);
|
||||
var password = btoa(getString(window.crypto.getRandomBytes(16)));
|
||||
password = password.substring(0, password.length - 2);
|
||||
var registrationId = new Uint16Array(window.crypto.getRandomBytes(2))[0];
|
||||
registrationId = registrationId & 0x3fff;
|
||||
|
||||
$('#init-go-single-client').click(function() {
|
||||
if (numberMatches()) {
|
||||
|
@ -73,7 +75,7 @@ $('#init-go').click(function() {
|
|||
$('#verify4done').html('');
|
||||
$('#verify').show();
|
||||
|
||||
API.confirmCode($('#code').val(), number, password, signaling_key, single_device,
|
||||
API.confirmCode($('#code').val(), number, password, signaling_key, registrationId, single_device,
|
||||
function(response) {
|
||||
if (single_device)
|
||||
response = 1;
|
||||
|
|
Loading…
Add table
Reference in a new issue