-
Notifications
You must be signed in to change notification settings - Fork 448
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Signup feature through Email in frontend (#828)
<!-- Add the issue number that is fixed by this PR (In the form Fixes #123) --> Fixes #821 #### Checklist - [x] I have read the [Contribution & Best practices Guide](https://blog.fossasia.org/open-source-developer-guide-and-best-practices-at-fossasia) and my PR follows them. - [x] My branch is up-to-date with the Upstream `development` branch. - [x] I have added necessary documentation (if appropriate) ### Preview Link - **Replace XXX with your PR no** - Link to live demo: http://pr-828-fossasia-badgeyay.surge.sh #### Changes proposed in this pull request: - Add Signup feature through Email in the frontend.
- Loading branch information
Showing
10 changed files
with
116 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import DS from 'ember-data'; | ||
|
||
const { JSONAPIAdapter } = DS; | ||
|
||
export default JSONAPIAdapter.extend({ | ||
host : 'http://localhost:5000', | ||
pathForType : () => { | ||
return 'api/user/signup'; | ||
} | ||
}); |
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 |
---|---|---|
@@ -1,4 +1,15 @@ | ||
import Controller from '@ember/controller'; | ||
|
||
import { inject as service } from '@ember/service'; | ||
|
||
export default Controller.extend({ | ||
routing : service('-routing'), | ||
actions : { | ||
signup(email, password) { | ||
this.get('store').createRecord('user-signup', { | ||
email, | ||
password | ||
}).push(); | ||
} | ||
} | ||
}); |
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,8 @@ | ||
import DS from 'ember-data'; | ||
|
||
const { Model, attr } = DS; | ||
|
||
export default Model.extend({ | ||
email : attr('string'), | ||
password : attr('string') | ||
}); |
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,21 @@ | ||
import DS from 'ember-data'; | ||
|
||
const { JSONAPISerializer } = DS; | ||
|
||
export default JSONAPISerializer.extend({ | ||
|
||
serialize(snapshot, options) { | ||
let json = this._super(...arguments); | ||
json.userSignup = { | ||
'email' : json.data.attributes.email, | ||
'password' : json.data.attributes.password | ||
}; | ||
|
||
delete json.data; | ||
return json; | ||
}, | ||
|
||
normalizeResponse(store, primaryModelClass, payload, id, requestType) { | ||
return payload; | ||
} | ||
}); |
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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
<div class="ui one column container stackable doubling centered grid"> | ||
<div class="column"> | ||
{{forms/signup-form}} | ||
{{forms/signup-form signUp=(action 'signUp')}} | ||
</div> | ||
</div> |
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,12 @@ | ||
import { module, test } from 'qunit'; | ||
import { setupTest } from 'ember-qunit'; | ||
|
||
module('Unit | Adapter | user signup', function(hooks) { | ||
setupTest(hooks); | ||
|
||
// Replace this with your real tests. | ||
test('it exists', function(assert) { | ||
let adapter = this.owner.lookup('adapter:user-signup'); | ||
assert.ok(adapter); | ||
}); | ||
}); |
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,14 @@ | ||
import { module, test } from 'qunit'; | ||
import { setupTest } from 'ember-qunit'; | ||
import { run } from '@ember/runloop'; | ||
|
||
module('Unit | Model | user signup', function(hooks) { | ||
setupTest(hooks); | ||
|
||
// Replace this with your real tests. | ||
test('it exists', function(assert) { | ||
let store = this.owner.lookup('service:store'); | ||
let model = run(() => store.createRecord('user-signup', {})); | ||
assert.ok(model); | ||
}); | ||
}); |
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,24 @@ | ||
import { module, test } from 'qunit'; | ||
import { setupTest } from 'ember-qunit'; | ||
import { run } from '@ember/runloop'; | ||
|
||
module('Unit | Serializer | user signup', function(hooks) { | ||
setupTest(hooks); | ||
|
||
// Replace this with your real tests. | ||
test('it exists', function(assert) { | ||
let store = this.owner.lookup('service:store'); | ||
let serializer = store.serializerFor('user-signup'); | ||
|
||
assert.ok(serializer); | ||
}); | ||
|
||
test('it serializes records', function(assert) { | ||
let store = this.owner.lookup('service:store'); | ||
let record = run(() => store.createRecord('user-signup', {})); | ||
|
||
let serializedRecord = record.serialize(); | ||
|
||
assert.ok(serializedRecord); | ||
}); | ||
}); |