-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #204 from linkernetworks/johnlin/resource-createdby
[Task] VX-233 johnlin/resource createdby
- Loading branch information
Showing
68 changed files
with
525 additions
and
229 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -72,10 +72,10 @@ Example: | |
```json | ||
{ | ||
"loginCredential":{ | ||
"email":"[email protected]", | ||
"username":"[email protected]", | ||
"password":"password" | ||
}, | ||
"username":"John Doe", | ||
"displayName":"John Doe", | ||
"firstName":"John", | ||
"lastName":"Doe", | ||
"phoneNumber":"0911111111" | ||
|
@@ -87,13 +87,11 @@ Response Data: | |
```json | ||
{ | ||
"id": "5b5b418c760aab15e771bde2", | ||
"uuid": "44b4646a-d009-457c-9fdd-1cc0bf226543", | ||
"jwt": "", | ||
"loginCredential": { | ||
"email": "[email protected]", | ||
"username": "[email protected]", | ||
"password": "$2a$14$XO4OOUCaiTNQHm.ZTzHU5..WwtP2ec2Q2HPPQuMHP1WoXCjXiRrxa" | ||
}, | ||
"username": "John Doe", | ||
"displayName": "John Doe", | ||
"role": "user", | ||
"firstName": "John", | ||
"lastName": "Doe", | ||
|
@@ -110,7 +108,7 @@ Example: | |
|
||
```json | ||
{ | ||
"email":"[email protected]", | ||
"username":"[email protected]", | ||
"password":"password" | ||
} | ||
``` | ||
|
@@ -135,11 +133,11 @@ role can only be "root", "user", "guest". | |
```json | ||
{ | ||
"loginCredential":{ | ||
"email":"[email protected]", | ||
"username":"[email protected]", | ||
"password":"password" | ||
}, | ||
"role": "guest", | ||
"username":"John Doe", | ||
"displayName":"John Doe", | ||
"firstName":"John", | ||
"lastName":"Doe", | ||
"phoneNumber":"0911111111" | ||
|
@@ -151,13 +149,11 @@ Response Data: | |
```json | ||
{ | ||
"id": "5b5b418c760aab15e771bde2", | ||
"uuid": "44b4646a-d009-457c-9fdd-1cc0bf226543", | ||
"jwt": "", | ||
"loginCredential": { | ||
"email": "[email protected]", | ||
"username": "[email protected]", | ||
"password": "$2a$14$XO4OOUCaiTNQHm.ZTzHU5..WwtP2ec2Q2HPPQuMHP1WoXCjXiRrxa" | ||
}, | ||
"username": "John Doe", | ||
"displayName": "John Doe", | ||
"role": "guest", | ||
"firstName": "John", | ||
"lastName": "Doe", | ||
|
@@ -181,13 +177,11 @@ Response Data: | |
[ | ||
{ | ||
"id": "5b5b4173760aab15e771bde0", | ||
"uuid": "52870ee9-4bfd-44ea-8cca-a9ce7826b1bd", | ||
"jwt": "", | ||
"loginCredential": { | ||
"email": "[email protected]", | ||
"username": "[email protected]", | ||
"password": "$2a$14$CQasyFUsBuqwmmpk/i9t9.9j2BTyPzK3PyWATMgb/7g8do57c9oHe" | ||
}, | ||
"username": "John Doe", | ||
"displayName": "John Doe", | ||
"role": "root", | ||
"firstName": "John", | ||
"lastName": "Doe", | ||
|
@@ -196,13 +190,11 @@ Response Data: | |
}, | ||
{ | ||
"id": "5b5b4184760aab15e771bde1", | ||
"uuid": "a4604f7d-06a8-4226-9792-765e72b14f9c", | ||
"jwt": "", | ||
"loginCredential": { | ||
"email": "[email protected]", | ||
"username": "[email protected]", | ||
"password": "$2a$14$SzULcUvWqsCy6XeelPdsRutCDJkdsrM4mi2HXpXPEaEugV.jJsMNC" | ||
}, | ||
"username": "John Doe", | ||
"displayName": "John Doe", | ||
"role": "user", | ||
"firstName": "John", | ||
"lastName": "Doe", | ||
|
@@ -211,13 +203,11 @@ Response Data: | |
}, | ||
{ | ||
"id": "5b5b418c760aab15e771bde2", | ||
"uuid": "44b4646a-d009-457c-9fdd-1cc0bf226543", | ||
"jwt": "", | ||
"loginCredential": { | ||
"email": "[email protected]", | ||
"username": "[email protected]", | ||
"password": "$2a$14$XO4OOUCaiTNQHm.ZTzHU5..WwtP2ec2Q2HPPQuMHP1WoXCjXiRrxa" | ||
}, | ||
"username": "John Doe", | ||
"displayName": "John Doe", | ||
"role": "guest", | ||
"firstName": "John", | ||
"lastName": "Doe", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,10 +40,10 @@ func (suite *AuthenticateTestSuite) SetupSuite() { | |
user := entity.User{ | ||
ID: bson.NewObjectId(), | ||
LoginCredential: entity.LoginCredential{ | ||
Email: "[email protected]", | ||
Username: "[email protected]", | ||
Password: hashedPassword, | ||
}, | ||
Username: "John Doe", | ||
DisplayName: "John Doe", | ||
FirstName: "John", | ||
LastName: "Doe", | ||
PhoneNumber: "091111l111", | ||
|
@@ -55,7 +55,7 @@ func (suite *AuthenticateTestSuite) SetupSuite() { | |
func (suite *AuthenticateTestSuite) TearDownSuite() { | ||
suite.session.Remove( | ||
entity.UserCollectionName, | ||
"loginCredential.email", | ||
"loginCredential.username", | ||
"[email protected]", | ||
) | ||
} | ||
|
@@ -66,18 +66,18 @@ func TestAuthenticateSuite(t *testing.T) { | |
|
||
func (suite *AuthenticateTestSuite) TestAuthenticate() { | ||
CorrectCred := entity.LoginCredential{ | ||
Email: "[email protected]", | ||
Username: "[email protected]", | ||
Password: suite.plainTextPassword, | ||
} | ||
user, passed, err := Authenticate(suite.session, CorrectCred) | ||
suite.NoError(err) | ||
suite.True(passed) | ||
suite.Equal(CorrectCred.Email, user.LoginCredential.Email) | ||
suite.Equal(CorrectCred.Username, user.LoginCredential.Username) | ||
} | ||
|
||
func (suite *AuthenticateTestSuite) TestFailedAuthenticate() { | ||
WrongCred := entity.LoginCredential{ | ||
Email: "[email protected]", | ||
Username: "[email protected]", | ||
Password: "wrongPasswordOX", | ||
} | ||
_, passed, err := Authenticate(suite.session, WrongCred) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package backend | ||
|
||
import ( | ||
"github.com/linkernetworks/mongo" | ||
"github.com/linkernetworks/vortex/src/entity" | ||
"gopkg.in/mgo.v2/bson" | ||
) | ||
|
||
func FindUserByID(session *mongo.Session, ID bson.ObjectId) (entity.User, error) { | ||
var user entity.User | ||
if err := session.FindOne( | ||
entity.UserCollectionName, | ||
bson.M{"_id": ID}, | ||
&user, | ||
); err != nil { | ||
return entity.User{}, err | ||
} | ||
return user, nil | ||
} |
Oops, something went wrong.