Skip to content

Commit

Permalink
added template atNavButton as for #133
Browse files Browse the repository at this point in the history
  • Loading branch information
splendido committed Oct 31, 2014
1 parent eb56b56 commit 92f3cf8
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 0 deletions.
8 changes: 8 additions & 0 deletions lib/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ AT.prototype.texts = {
mustBeLoggedIn: "error.accounts.Must be logged in",
pwdMismatch: "error.pwdsDontMatch",
},
navSignIn: 'signIn',
navSignOut: 'signOut',
info: {
emailSent: "info.emailSent",
emailVerified: "info.emailVerified",
Expand Down Expand Up @@ -426,6 +428,12 @@ AT.prototype.linkClick = function(route){
});
};

AT.prototype.logout = function(){
Meteor.logout();
var homeRoutePath = AccountsTemplates.options.homeRoutePath;
if (homeRoutePath)
Router.go(homeRoutePath);
};

AT.prototype.postSubmitRedirect = function(route){
if (AccountsTemplates.avoidRedirect)
Expand Down
2 changes: 2 additions & 0 deletions lib/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ INFO_PAT = {
TEXTS_PAT = {
button: Match.Optional(STATE_PAT),
errors: Match.Optional(ERRORS_PAT),
navSignIn: Match.Optional(String),
navSignOut: Match.Optional(String),
info: Match.Optional(INFO_PAT),
optionalField: Match.Optional(String),
pwdLink_pre: Match.Optional(String),
Expand Down
15 changes: 15 additions & 0 deletions lib/templates_helpers/at_nav_button.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
AT.prototype.atNavButtonHelpers = {
text: function(){
var key = Meteor.user() ? AccountsTemplates.texts.navSignOut : AccountsTemplates.texts.navSignIn;
return T9n.get(key, markIfMissing=false);
}
};

AT.prototype.atNavButtonEvents = {
'click #at-nav-button': function(event){
if (Meteor.user())
AccountsTemplates.logout();
else
Router.go('atSignIn');
},
};
1 change: 1 addition & 0 deletions package.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ Package.on_use(function(api) {
"lib/templates_helpers/at_error.js",
"lib/templates_helpers/at_form.js",
"lib/templates_helpers/at_input.js",
"lib/templates_helpers/at_nav_button.js",
"lib/templates_helpers/at_oauth.js",
"lib/templates_helpers/at_pwd_form.js",
"lib/templates_helpers/at_pwd_form_btn.js",
Expand Down

0 comments on commit 92f3cf8

Please sign in to comment.