meteorite - How to display Meteor.loginWithPassword callbak error message on the same page -
I created a custom login page and used The login template is the following: As I debugging, I can see that an error message is displayed and added to the Dome. But it will be refreshing and the message will disappear. Meteor.loginWithPassword () is the meteor after the page mentioned again? When using meteor, if you find yourself injecting HTML elements with jQuery, how can you remove it? In your alert container, conditionally an error message: In your login callback, set Finally, add a template assistant to use the Meteor.loginWithPassword (user, password, [callback]) function to login in the app.
& lt; Template name = "Login" & gt; & Lt; Form class = "login-form form-horizontal" & gt; & Lt; Div class = "control-group" & gt; & Lt; Input class = "email" type = "text" placeholder = "email" & gt; & Lt; / Div & gt; & Lt; Div class = "control-group m-inputwrapper" & gt; & Lt; Input class = "password" type = "password" placeholder = "password" & gt; & Lt; / Div & gt; & Lt; Div class = "control-group" & gt; & Lt; Button type = "submit" class = "submit t-btn-login" & gt; Login & lt; / Button & gt; & Lt; / Div & gt; & Lt; / Form & gt; & Lt; Div class = "alert-container" & gt; & Lt; Div class = "alert-placeholder" & gt; & Lt; / Div & gt; & Lt; / Div & gt; & Lt; / Template & gt; Template.Login.events ({'Submit .login-form': function (e, t) {e.preventDefault (); // input field values var email = t.find ('. Email') Value, password = t.find ('.password'). Value; Meteor.loginWithPassword (email, password, function (error) {$ (".path-placeholder"). Html ('& lt ; div>
& lt; Div class = "alert-container" & gt; {{#if error message}} & lt; Div class = "alert" & gt; & Lt; Span & gt; & Lt; I class = "icon-mark" & gt; & Lt; / I & gt; {{Error message}} & lt; / Span & gt; & Lt; / Div & gt; {{/ If}} & lt; / Div & gt; error message err exists:
Meteor.loginWithPassword (email, password, function (error) {if (err) {session .set ('errorMessage', err.message);}}); error message session variable:
Template.Login.helpers ({errorMessage: function () {return Session.get ('errorMessage');}});
Comments
Post a Comment