Skip to content

Commit 80d4c8c

Browse files
author
elijah
committed
Merge pull request #107 from apinf/feature/api-key-field-userprofile
Feature/api key field userprofile
2 parents eb4dea2 + aa6f614 commit 80d4c8c

File tree

3 files changed

+33
-2
lines changed

3 files changed

+33
-2
lines changed

.meteor/versions

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ blaze@2.1.2
2020
blaze-tools@1.0.3
2121
boilerplate-generator@1.0.3
2222
bootstrap@0.3.1
23-
brylie:api-umbrella@0.2.2
23+
brylie:api-umbrella@0.2.3
2424
callback-hook@1.0.3
2525
cfs:access-point@0.1.49
2626
cfs:base-package@0.0.30

collections/users.coffee

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,12 @@ Schemas.UserProfile = new SimpleSchema(
1717
type: String
1818
optional: true
1919

20+
apiKey:
21+
label: 'API key (optional)'
22+
type: String,
23+
regEx: /^[a-z0-9A-Z]{40}$/,
24+
optional: true,
25+
2026
)
2127

2228
Schemas.User = new SimpleSchema(
@@ -26,7 +32,10 @@ Schemas.User = new SimpleSchema(
2632
regEx: /^[a-z0-9A-Z_]{3,15}$/
2733
optional: true
2834

29-
35+
apiUmbrellaUserId:
36+
type: String
37+
optional: true
38+
3039
emails:
3140
type: [Object]
3241
optional: true

server/accounts.coffee

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,26 @@ Accounts.onCreateUser (options, user) ->
4141
profilePicture = ProfilePictures.insert picture
4242
user.profile.picture = profilePicture._id
4343

44+
# apiumbrella user obect to be send to apiUmbrellaWeb
45+
apiUmbrellaUserObj = {
46+
"user":{
47+
"email": user.emails[0].address,
48+
"first_name": "-",
49+
"last_name": "-",
50+
"terms_and_conditions":true
51+
}
52+
}
53+
54+
response = apiUmbrellaWeb.adminApi.v1.apiUsers.createUser(apiUmbrellaUserObj)
55+
56+
# adding to Aping user object ID of just created apiUmbrella User
57+
user.apiUmbrellaUserId = response.data.user.id
58+
59+
# adding Api key to user profile
60+
# TODO: make apiKey field not editable or display api key on profile page separately from form - as a plain text
61+
user.profile.apiKey = response.data.user.api_key
62+
63+
# adding umbrella user to apinf database
64+
ApiUmbrellaUsers.insert(response.data.user)
65+
4466
user

0 commit comments

Comments
 (0)