def post(self):
        args = resendEmailPostParser.parse_args()
        email = args.get('email')
        os = args.get('os')
        browser = args.get('browser')
        site_url = args.get('site_url', current_app.config['SITE_URL'])        

        user = check_email_exists(email)
        if user:
            token = generate_confirmation_token(email)
            site_url = '%s://%s' % (current_app.config['PREFERRED_URL_SCHEME'], site_url)
            confirm_url = '%s/auth/activate/%s' % (site_url, token)
            html = render_template('confirm_email.html',
                username=user.username,
                confirm_url=confirm_url,
                site_url=site_url,
                support_url='mailto:[email protected]',
                os=os,
                browser=browser
            )
            send_email(email, 'Activate Your DIVE Account', html)
            return jsonify({
                'status': 'success',
                'message': 'A confirmation e-mail has been sent to %s' % email
            })
        else:
            return jsonify({
                'status': 'error',
                'message': 'No account corresponds to that e-mail address.'
            }, status=401)
    def post(self):
        args = registerPostParser.parse_args()
        user_id = args.get('user_id')
        username = args.get('username')
        name = args.get('name')
        email = args.get('email')
        password = args.get('password')
        os = args.get('os')
        browser = args.get('browser')
        remember = args.get('rememberMe', True)
        site_url = args.get('site_url', current_app.config['SITE_URL'])

        registration_result, valid_registration = validate_registration(username, email)

        if valid_registration:
            confirmed = (False if current_app.config['MAIL_AUTHENTICATION'] else True)

            user = register_user(
                username,
                email,
                password,
                user_id=user_id,
                confirmed=confirmed,
                anonymous=False
            )

            login_user(user, remember=remember)
            parsed_user = row_to_dict(user)

            if current_app.config['MAIL_AUTHENTICATION']:
                site_url = '%s://%s' % (current_app.config['PREFERRED_URL_SCHEME'], site_url)
                token = generate_confirmation_token(email)
                confirm_url = '%s/auth/activate/%s' % (site_url, token)
                html = render_template('confirm_email.html',
                    username=username,
                    confirm_url=confirm_url,
                    site_url=site_url,
                    support_url='mailto:[email protected]',
                    os=os,
                    browser=browser
                )
                send_email(email, 'Activate Your DIVE Account', html)
                message = 'A confirmation e-mail has been sent to %s' % email
            else:
                message = 'Successfully registered'

            response = jsonify({
                'status': 'success',
                'message': message,
                'user': { k: parsed_user[k] for k in ['anonymous', 'confirmed', 'email', 'id', 'username']}
            })                

            response = set_cookies(response, {
                'username': user.username,
                'email': user.email,
                'user_id': user.id,
                'confirmed': user.confirmed,
                'anonymous': user.anonymous
            }, expires=datetime.utcnow() + COOKIE_DURATION)
            return response

        else:
            return jsonify({
                'status': 'error',
                'message': registration_result
            }, status=401)