From 2da5b12c31074591eaf16929b760322b98f189e8 Mon Sep 17 00:00:00 2001 From: jloup Date: Fri, 11 May 2018 13:57:29 +0200 Subject: Mails. --- cmd/app/main.go | 4 +++- cmd/web/js/api.js | 10 ++++++++++ cmd/web/js/main.jsx | 25 +++++++++++++++++++++++-- 3 files changed, 36 insertions(+), 3 deletions(-) (limited to 'cmd') diff --git a/cmd/app/main.go b/cmd/app/main.go index 28eb775..e414bf2 100644 --- a/cmd/app/main.go +++ b/cmd/app/main.go @@ -22,12 +22,12 @@ type AppConfig struct { type ApiConfig struct { api.Config - Domain string `toml:"domain"` } type Config struct { App AppConfig Api ApiConfig + Mail api.MailConfig Db db.DBConfig Redis db.RedisConfig @@ -61,6 +61,7 @@ func init() { } api.SetConfig(C.Api.Config) + api.SetMailConfig(C.Mail) db.Init(C.Db, C.Redis) @@ -139,6 +140,7 @@ func main() { "/", "/signup", "/signin", + "/confirm", "/reset-password", "/change-password", "/signout", diff --git a/cmd/web/js/api.js b/cmd/web/js/api.js index f892a6b..62530ba 100644 --- a/cmd/web/js/api.js +++ b/cmd/web/js/api.js @@ -64,6 +64,16 @@ var ApiEndpoints = { return '/changepassword'; } }, + 'CONFIRM_EMAIL': { + 'type': 'POST', + 'auth': false, + 'parameters': [ + {'name': 'token', 'mandatory': true, 'inquery': true}, + ], + 'buildUrl': function() { + return '/confirmemail'; + } + }, 'MARKET': { 'type': 'GET', 'auth': true, diff --git a/cmd/web/js/main.jsx b/cmd/web/js/main.jsx index 84b5848..5dc45eb 100644 --- a/cmd/web/js/main.jsx +++ b/cmd/web/js/main.jsx @@ -62,6 +62,27 @@ App.page('/change-password', false, function(context) { ); }); +App.page('/confirm', false, function(context) { + var token = qs.parse(context.querystring).token; + + if (token === undefined) { + App.go('/'); + return; + } + + Api.Call( + 'CONFIRM_EMAIL', + {'token': token}, + function(err, status, data) { + if (err) { + console.error(err, data); + } + + App.go('/me'); + } + ); +}); + App.page('/signout', true, function(context) { cookies.removeItem('jwt'); @@ -84,8 +105,8 @@ App.page('/not_confirmed', true, function(context) { App.mount(
-

Please be patient, you account is being confirmed...

-

Refresh

+

An email has now been sent to your email address.

+

Please click the "Confirm your account" button to validate your email.

); -- cgit v1.2.3