mirror of
https://github.com/vale981/Vulcan
synced 2025-03-06 01:51:40 -05:00
adding user_email template
This commit is contained in:
parent
ce11b81f29
commit
844ce3ce45
5 changed files with 92 additions and 21 deletions
|
@ -151,7 +151,8 @@ if (Meteor.is_client) {
|
|||
|
||||
var Router = new SimpleRouter();
|
||||
Meteor.startup(function() {
|
||||
Backbone.history.start({pushState: true});
|
||||
if(!Backbone.history._hasPushState)
|
||||
Backbone.history.start({pushState: true});
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -8,19 +8,31 @@
|
|||
{{/if}}
|
||||
<form>
|
||||
<h2>Account</h2>
|
||||
{{#if username}}
|
||||
<div class="control-group">
|
||||
<label>Username</label>
|
||||
<div class="controls"><input id="username" name="username" disabled="disabled" type="text" value="{{username}}" /></div>
|
||||
<div class="controls">
|
||||
<input id="username" name="username" disabled="disabled" type="text" value="{{username}}" />
|
||||
</div>
|
||||
</div>
|
||||
{{/if}}
|
||||
<!-- <div class="control-group">
|
||||
<label>Email</label>
|
||||
<div class="controls">
|
||||
<input id="email" name="email" disabled="disabled" type="text" value="{{email}}" />
|
||||
</div>
|
||||
</div> -->
|
||||
<div class="control-group">
|
||||
<label>Display Name</label>
|
||||
<div class="controls">
|
||||
<input name="name" type="text" value="{{profile.name}}" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<label>Email</label>
|
||||
<div class="controls"><input id="email" name="email" disabled="disabled" type="text" value="{{email}}" /></div>
|
||||
<label>Display Name</label>
|
||||
<div class="controls"><input name="name" type="text" value="{{profile.name}}" /></div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<label>Email 2</label>
|
||||
<div class="controls"><input name="email" type="text" value="{{profile.email}}" /></div>
|
||||
<div class="controls">
|
||||
<input name="email" type="text" value="{{profile.email}}" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<label>Bio</label>
|
||||
|
|
|
@ -1,23 +1,21 @@
|
|||
(function(){
|
||||
|
||||
Template.user_edit.events = {
|
||||
'submit form': function(e){
|
||||
e.preventDefault();
|
||||
if(!Meteor.user()) throw 'You must be logged in.';
|
||||
$target=$(e.target);
|
||||
if(!Meteor.user()) throwError('You must be logged in.');
|
||||
|
||||
var user=window.selected_user_id? Meteor.users.findOne(window.selected_user_id) : Meteor.user();
|
||||
var update = {
|
||||
"profile.name": $(e.target).find('[name=name]').val(),
|
||||
"profile.bio": $(e.target).find('[name=bio]').val()
|
||||
"profile.name": $target.find('[name=email]').val()
|
||||
};
|
||||
|
||||
// TODO: enable change email
|
||||
var email = $(e.target).find('[name=email]').val();
|
||||
|
||||
var old_password = $(e.target).find('[name=old_password]').val();
|
||||
var new_password = $(e.target).find('[name=new_password]').val();
|
||||
var old_password = $target.find('[name=old_password]').val();
|
||||
var new_password = $target.find('[name=new_password]').val();
|
||||
|
||||
// XXX we should do something if there is an eeror updating these things
|
||||
// XXX we should do something if there is an error updating these things
|
||||
if(old_password && new_password){
|
||||
Meteor.changePassword(old_password, new_password);
|
||||
}
|
||||
|
@ -36,7 +34,7 @@ Template.user_edit.events = {
|
|||
};
|
||||
|
||||
Template.user_edit.profileIncomplete = function() {
|
||||
return !this.loading && !userProfileComplete(this);
|
||||
return Meteor.user() && !this.loading && !userProfileComplete(this);
|
||||
}
|
||||
|
||||
Template.user_edit.user = function(){
|
||||
|
@ -46,6 +44,4 @@ Template.user_edit.user = function(){
|
|||
}else{
|
||||
return current_user;
|
||||
}
|
||||
}
|
||||
|
||||
})();
|
||||
}
|
23
client/templates/user_email.html
Normal file
23
client/templates/user_email.html
Normal file
|
@ -0,0 +1,23 @@
|
|||
<template name="user_email">
|
||||
<div class="grid-small grid-block dialog user-edit">
|
||||
{{#with user}}
|
||||
{{#if profileIncomplete}}
|
||||
<div>
|
||||
Please add your email below before continuing.
|
||||
</div>
|
||||
{{/if}}
|
||||
<form>
|
||||
<div class="control-group">
|
||||
<label>Email</label>
|
||||
<div class="controls">
|
||||
<input name="email" type="text" value="{{profile.email}}" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-actions">
|
||||
<a href="/forgot_password">Forgot password?</a>
|
||||
<input type="submit" class="button" value="Submit" />
|
||||
</div>
|
||||
</form>
|
||||
{{/with}}
|
||||
</div>
|
||||
</template>
|
39
client/templates/user_email.js
Normal file
39
client/templates/user_email.js
Normal file
|
@ -0,0 +1,39 @@
|
|||
Template.user_edit.events = {
|
||||
'submit form': function(e){
|
||||
e.preventDefault();
|
||||
if(!Meteor.user()) throwError('You must be logged in.');
|
||||
|
||||
var user=window.selected_user_id? Meteor.users.findOne(window.selected_user_id) : Meteor.user();
|
||||
var update = {
|
||||
"profile.name": $(e.target).find('[name=name]').val(),
|
||||
"profile.bio": $(e.target).find('[name=bio]').val()
|
||||
};
|
||||
|
||||
// TODO: enable change email
|
||||
var email = $(e.target).find('[name=email]').val();
|
||||
|
||||
Meteor.users.update(user._id, {
|
||||
$set: update
|
||||
}, function(error){
|
||||
if(error){
|
||||
throwError(error.reason);
|
||||
} else {
|
||||
throwError('Profile updated');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
Template.user_edit.profileIncomplete = function() {
|
||||
return Meteor.user() && !this.loading && !userProfileComplete(this);
|
||||
}
|
||||
|
||||
Template.user_edit.user = function(){
|
||||
var current_user=Meteor.user();
|
||||
if(window.selected_user_id && !current_user.loading && current_user.isAdmin){
|
||||
return Meteor.users.findOne(window.selected_user_id);
|
||||
}else{
|
||||
return current_user;
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue