Repository: hedyorg/hedy

Issue:
Implement landing page when verifying mail address
Currently when verifying your mail address after creating an account you land on the homepage; giving the user no information if the verification of the mail address was successful. It would be nice to return the user with some additional information such as "your account is successful verified". We can implement this by creating an additional "landing" page when clicking the verify link in the mail with (maybe) an automatic re-direct to the homepage after x seconds.


Discussion:
Hi @TiBiBa 

I am browsing old issues and this might be a small one for you to pick up yourself? 
Yes, will pick this up!
Maybe it could be combined with this one: https://github.com/Felienne/hedy/issues/722 (for teachers, but maybe also for new accounts in general)

Resolving patch:
diff --git a/app.py b/app.py
--- a/app.py
+++ b/app.py
@@ -914,6 +914,12 @@ def main_page(page):
     if page == 'programs':
         return programs_page(request)
 
+    if page == 'landing-page':
+        if current_user()['username']:
+            return render_template('landing-page.html', user=current_user()['username'], is_teacher=is_teacher(current_user()), auth=TRANSLATIONS.get_translations(g.lang, 'Auth'), text=TRANSLATIONS.get_translations(g.lang, 'Landing_page'))
+        else:
+            return utils.page_403(TRANSLATIONS, current_user()['username'], g.lang, TRANSLATIONS.get_translations(g.lang, 'ui').get('not_user'))
+
     # Default to English if requested language is not available
     effective_lang = g.lang if path.isfile(f'main/{page}-{g.lang}.md') else 'en'
 
@@ -926,6 +932,7 @@ def main_page(page):
     front_matter, markdown = split_markdown_front_matter(contents)
 
     user = current_user()
+
     if page == 'for-teachers':
         if is_teacher(user):
             welcome_teacher = session.get('welcome-teacher') or False
@@ -937,7 +944,6 @@ def main_page(page):
         else:
             return utils.page_403 (TRANSLATIONS, current_user()['username'], g.lang, TRANSLATIONS.get_translations (g.lang, 'ui').get ('not_teacher'))
 
-
     return render_template('main-page.html', mkd=markdown, auth=TRANSLATIONS.get_translations(g.lang, 'Auth'), **front_matter)
 
 
diff --git a/website/auth.py b/website/auth.py
--- a/website/auth.py
+++ b/website/auth.py
@@ -294,7 +294,7 @@ def verify_email():
 
         # If user is verified, succeed anyway
         if not 'verification_pending' in user:
-            return redirect('/')
+            return redirect('/landing-page')
 
         if token != user['verification_pending']:
             return 'invalid username/token', 403


Test patch:
diff --git a/tests_e2e.py b/tests_e2e.py
--- a/tests_e2e.py
+++ b/tests_e2e.py
@@ -350,7 +350,7 @@ def test_verify_email(self):
         # WHEN attepting to verify the user again (the operation should be idempotent)
         # THEN (again) receive a redirect from the server taking us to `/`
         headers = self.get_data('auth/verify?' + urllib.parse.urlencode({'username': self.username, 'token': self.user['verify_token']}), expect_http_code=302, return_headers=True)
-        self.assertEqual(headers['location'], HOST)
+        self.assertEqual(headers['location'], HOST + 'landing-page')
 
         # WHEN retrieving profile to see that the user is no longer marked with `verification_pending`
         self.given_specific_user_is_logged_in(self.username)