Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added groups in identity registration #215

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion dist/tozny-sodium.min.js

Large diffs are not rendered by default.

16 changes: 9 additions & 7 deletions lib/identity/realm.js
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,8 @@ class Realm extends CryptoConsumer {
firstName,
lastName,
emailEACPExpiryMinutes = 60,
attributes
attributes,
groups = []
) {
username = username.toLowerCase()
const cryptoKeys = await this.storage.generateKeypair()
Expand All @@ -213,6 +214,7 @@ class Realm extends CryptoConsumer {
last_name: lastName,
email: email,
attributes: attributes,
groups: groups
},
}
const request = await fetch(this.apiUrl + '/v1/identity/register', {
Expand Down Expand Up @@ -629,7 +631,7 @@ class Realm extends CryptoConsumer {
body: JSON.stringify(payload),
}
)
} catch(e) {
} catch (e) {
throw new Error(
'Could not write TozIdEACP Challenge.'
)
Expand Down Expand Up @@ -979,12 +981,12 @@ class Realm extends CryptoConsumer {
body: JSON.stringify(payload),
}
)
if(registerRequest.status == 200) {
if (registerRequest.status == 200) {
const registerResponse = await validateResponseAsJSON(registerRequest)
const identity = await this.toznyRecovery(registerResponse.tozid_otp, registerResponse.note_id)
username = registerResponse.username
await writePasswordNote(identity, password, true)
} else if(registerRequest.status == 201) {
} else if (registerRequest.status == 201) {
const registerResponse = await validateResponseAsJSON(registerRequest)
const identityConfig = new Config(
realmInfo.name,
Expand Down Expand Up @@ -1023,11 +1025,11 @@ class Realm extends CryptoConsumer {
false,
60
)
username = registerResponse.identity.name
} else if(registerRequest.status == 303) {
username = registerResponse.identity.name
} else if (registerRequest.status == 303) {
restrictedLogin = true;
}
return {username, password, restrictedLogin}
return { username, password, restrictedLogin }
}
}

Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@toznysecure/sdk",
"version": "1.5.16-alpha.64",
"version": "1.5.16-alpha.66",
"description": "Tozny Platform software developers kit.",
"main": "index.js",
"engines": {
Expand Down