Added User profiles so users can change their username

This commit is contained in:
Thaum
2015-03-31 11:38:09 +00:00
parent 51d697b894
commit dad9f3dd73
14 changed files with 136 additions and 50 deletions

View File

@@ -0,0 +1,24 @@
<template name="profile">
{{#with currentUser}}
<core-toolbar class="blue-grey white-text">
<core-icon-button icon="menu" core-drawer-toggle></core-icon-button>
<div id="username" class="clickable" flex>
{{#if username}}
{{username}}
{{else}}
Tap to set username
{{/if}}
</div>
</core-toolbar>
<div id="userProfile" class="padded">
<div>
<h2>Email</h2>
{{#each emails}}
<div layout horizontal>
<p>{{address}}</p>
</div>
{{/each}}
</div>
</div>
{{/with}}
</template>

View File

@@ -0,0 +1,19 @@
Template.profile.events({
"tap #username": function(){
if(this._id === Meteor.userId()){
GlobalUI.showDialog({
heading: "Change Username",
template: "usernameDialog"
});
}
},
"tap #verifyEmail": function(event, instance){
if(!Meteor.user()) return;
Accounts.sendVerificationEmail(Meteor.userId(), this.address);
GlobalUI.toast({
text: "Email verification sent to " + this.address,
template: "",
data: {}
});
}
});

View File

@@ -0,0 +1,9 @@
<template name="usernameDialog">
{{#with currentUser}}
<div>
<paper-input id="usernameInput" label="Username" value={{username}}></paper-input>
</div>
{{/with}}
<paper-button id="cancelButton" affirmative> Cancel </paper-button>
<paper-button id="changeButton" affirmative> Change Username </paper-button>
</template>

View File

@@ -0,0 +1,5 @@
Template.usernameDialog.events({
"tap #changeButton": function(event, instance){
Meteor.users.update(Meteor.userId(), {$set: {username: instance.find("#usernameInput").value}});
}
});