diff options
| author | Jules Laplace <julescarbon@gmail.com> | 2017-12-12 02:09:15 +0100 |
|---|---|---|
| committer | Jules Laplace <julescarbon@gmail.com> | 2017-12-12 02:09:15 +0100 |
| commit | 41d0bd185c19c8a51ed9b85700f52181b6cc5012 (patch) | |
| tree | 76d4524fff4221da47e57ea0bcdb0917d592b5d1 /public/assets/js/lib/views/login | |
| parent | ce73133c4e982db99f218bf930d82eb991ce81e3 (diff) | |
color stuff, building settings form
Diffstat (limited to 'public/assets/js/lib/views/login')
| -rw-r--r-- | public/assets/js/lib/views/login/signup.js | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/public/assets/js/lib/views/login/signup.js b/public/assets/js/lib/views/login/signup.js new file mode 100644 index 0000000..d3d407d --- /dev/null +++ b/public/assets/js/lib/views/login/signup.js @@ -0,0 +1,49 @@ +var SignupView = FormView.extend({ + + el: "#signup", + action: "/api/signup", + method: "put", + + initialize: function(opt){ + this.__super__.initialize.call(this) + $("body").removeClass("loading") + this.$("[name=username]").focus() + }, + + validate: function(){ + var errors = [] + if (! this.$("[name=username]").val().length) { + errors.push("Please enter a username") + } + if (! this.$("[name=password]").val().length) { + errors.push("Please enter a password") + } + if (this.$("[name=password]").val() !== this.$("[name=password2]").val()) { + errors.push("Passwords don't match") + } + return errors.length ? errors : null + }, + + showErrors: function(errors){ + $(".errors").show().css({ opacity: 1 }).html(errors.join("<br>")) + }, + + success: function(data){ + console.log("LOGGED IN?", data) + if (data.user) { + auth.set_user(data.user) + } + else { + this.showErrors() + return + } + if (data.returnTo) { + console.log(data.returnTo) + window.location.href = data.returnTo + } + else { + window.location.href = "/index" + } + }, + +}) |
