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

User Email Check on Signup #1993

Closed
Closed
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
11 changes: 11 additions & 0 deletions api/controllers/registerUser.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,16 @@
router = Blueprint('registerUser', __name__)


@router.route('/checkemail', methods=['GET'])
def check_user():
email = request.args.get('email',1,type=str)
print(email)
if auth.check_user_by_email(email) == "EXISTS":
print("exists")
return jsonify({"data":{"attributes":{"exist":"Email Exists"},"links":{"self":"/user/checkemail"},"type":"checkuser","id":"null"},"links":{"self":"check-email"}})
else :
return jsonify({"data":{"attributes":{"exist":"Email Available"},"links":{"self":"/user/checkemail"},"type":"checkuser","id":"null"},"links":{"self":"check-email"}})

@router.route('/register', methods=['POST'])
def register_user():
schema = UserSchema()
Expand Down Expand Up @@ -88,6 +98,7 @@ def register_user():
perm.save_to_db()
else:
newUser = user_
print(jsonify(schema.dump(newUser).data))
return jsonify(schema.dump(newUser).data)


Expand Down
12 changes: 12 additions & 0 deletions frontend/app/adapters/checkuser.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import DS from 'ember-data';
import ENV from '../config/environment';

const { APP } = ENV;
const { JSONAPIAdapter } = DS;

export default JSONAPIAdapter.extend({
host : APP.backLink,
pathForType : () => {
return 'user/checkemail';
}
});
9 changes: 9 additions & 0 deletions frontend/app/components/forms/signup-form.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,15 @@ export default Component.extend({
}
}
},
emailcheck(event) {
var email = $('#email').val();
var regex = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,6}$/;
if (regex.test(email)) {
this.get('emailcheck')(email);
} else {
$('#emailstatus').text('Email Invalid');
}
},
showPasswordSignupConfirm() {
function show() {
$('#pwdConfirm').attr('type', 'text');
Expand Down
12 changes: 6 additions & 6 deletions frontend/app/controllers/signup.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Controller from '@ember/controller';

import $ from 'jquery';
import { inject as service } from '@ember/service';

export default Controller.extend({
Expand Down Expand Up @@ -30,13 +30,13 @@ export default Controller.extend({
clearDuration : 1500
});
});
} else {
_this.get('notifications').error('Sign Up Failed ! Please try again', {
autoClear : true,
clearDuration : 1500
});
}
});
},
emailcheck(email) {
this.get('store').queryRecord('checkuser', { email }).then(function(data) {
$('#emailstatus').text(data.get('exist'));
});
}
}
});
8 changes: 8 additions & 0 deletions frontend/app/models/checkuser.js
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'),
exist : attr('string')
});
4 changes: 4 additions & 0 deletions frontend/app/styles/partials/signup.scss
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ $colorwhite: #ffffff;
top: 40px;
}

#emailstatus {
text-align: center;
}

.form {
.ending-border {
border-bottom: 0.01rem dotted;
Expand Down
4 changes: 3 additions & 1 deletion frontend/app/templates/components/forms/signup-form.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@
<div class="field required">
<div class="ui left icon input">
<i class="mail icon"></i>
{{input type="text" value=email name="email" placeholder="E-mail address"}}
{{input type="text" value=email name="email" id="email" keyPress=(action 'emailcheck') placeholder="E-mail address"}}
</div>
<div id="emailstatus" ></div>
</div>

<div class="field required">
<div class="ui left icon input">
<i class="user icon"></i>
Expand Down
2 changes: 1 addition & 1 deletion frontend/app/templates/signup.hbs
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 signUp=(action 'signUp')}}
{{forms/signup-form signUp=(action 'signUp') emailcheck=(action 'emailcheck')}}
</div>
</div>