Skip to content
This repository has been archived by the owner on Dec 13, 2018. It is now read-only.

View fixes #600

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions docs/templates.rst
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ in the source code: https://github.com/stormpath/stormpath-express/tree/master/l

.. note::

Our library includes Jade and our default templates are written in Jade. If you
are using custom templates that are not written in Jade, you must enable a
Our library includes Pug and our default templates are written in Pug. If you
are using custom templates that are not written in Pug, you must enable a
view renderer in your Express application. Please see
`Using template engines with Express`_.

Expand Down
2 changes: 1 addition & 1 deletion lib/controllers/login.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ module.exports = function (req, res, next) {
var oauthStateToken = oauth.common.resolveStateToken(req, res);

var hasSocialProviders = _.some(config.web.social, function (socialProvider) {
return socialProvider.enabled;
return socialProvider.providerId !== 'saml' && socialProvider.enabled;
});

extend(options, {
Expand Down
20 changes: 10 additions & 10 deletions lib/helpers/render.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,31 @@

var path = require('path');

var jade = require('jade');
var pug = require('pug');
var mixin = require('utils-merge');

var viewCache = {};

function renderJade(filepath, locals) {
function renderPug(filepath, locals) {
var env = process.env.NODE_ENV;

if (env === 'production') {
if (!viewCache[filepath]) {
viewCache[filepath] = jade.compileFile(filepath);
viewCache[filepath] = pug.compileFile(filepath);
}

return viewCache[filepath](locals);
}

return jade.renderFile(filepath, locals);
return pug.renderFile(filepath, locals);
}

/**
* Render a view using app locals.
*
* By default, use Jade as it is necessary because our library can't rely
* on the developer using Jade view as well -- so this allows us to use
* Jade templates for our library views, without negatively affecting the
* By default, use Pug as it is necessary because our library can't rely
* on the developer using Pug view as well -- so this allows us to use
* Pug templates for our library views, without negatively affecting the
* developer's application.
*
* If, however, the developer has supplied a render handler in their settings,
Expand All @@ -52,9 +52,9 @@ module.exports = function (req, res, view, options) {
if (!extension && (filename === view)) {
// This means that we have received a default config option, such as
// 'login' - just continue to render our default page.
res.send(renderJade(path.join(path.dirname(__dirname), 'views', view + '.jade'), options));
} else if (extension === '.jade') {
res.send(renderJade(view, options));
res.send(renderPug(path.join(path.dirname(__dirname), 'views', view + '.pug'), options));
} else if (extension === '.pug') {
res.send(renderPug(view, options));
} else if (extension) {
// Delegate to the view engine.
res.render(view, options);
Expand Down
6 changes: 5 additions & 1 deletion lib/middleware/groups-required.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,11 @@ module.exports = function (groups, all) {
isUserInGroups(function (err, isInGroup) {
if (err || !isInGroup) {
res.status(403);
return helpers.render(req, res, 'unauthorized');
var view = config.web.unauthorized && config.web.unauthorized.view
? config.web.unauthorized.view
: 'unauthorized';

return helpers.render(req, res, view);
}

next();
Expand Down
16 changes: 13 additions & 3 deletions lib/views/base.jade → lib/views/base.pug
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ html(class='no-js', lang='en')
head
meta(charset='utf-8')
title #{title}
meta(content='#{description}', name='description')
meta(content=description, name='description')
meta(content='width=device-width', name='viewport')
link(href='//fonts.googleapis.com/css?family=Open+Sans:300italic,300,400italic,400,600italic,600,700italic,700,800italic,800', rel='stylesheet', type='text/css')
link(href='//netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css', rel='stylesheet')
Expand Down Expand Up @@ -219,7 +219,6 @@ html(class='no-js', lang='en')
.view a.forgot,
.view a.to-login {
float: right;
padding: 17px 0;
font-size: 13px;
}

Expand Down Expand Up @@ -296,12 +295,23 @@ html(class='no-js', lang='en')
margin-top: 2em;
}

.login-view .forgot-password-area {
padding: 17px 15px;
}

@media (min-width: 767px) {
.login-view .forgot-password-area {
padding: 17px 50px;
}
}

.login-view .email-password-area {
background-color: white;
border-top-left-radius: 3px;
border-bottom-left-radius: 3px;
}


@media (min-width: 767px) {
.login-view .email-password-area {
padding: 0 30px;
Expand Down Expand Up @@ -410,7 +420,7 @@ html(class='no-js', lang='en')

block head

body(class='#{bodytag}')
body(class=bodytag)

block body

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,4 @@ block body
button.login.btn.btn-login.btn-sp-green(type='submit') Send Email

if stormpathConfig.web.login.enabled
a.forgot(href="#{stormpathConfig.web.login.uri}") Back to Log In
a.forgot(href=stormpathConfig.web.login.uri) Back to Log In
20 changes: 11 additions & 9 deletions lib/views/login.jade → lib/views/login.pug
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,10 @@ block body
p.
Before you can log into your account, you need to activate your
account by clicking the link we sent to your inbox.
p.
Didn't get the email? <a href="#{stormpathConfig.web.verifyEmail.uri}">Click Here</a>.
p
| Didn't get the email?
a(href=stormpathConfig.web.verifyEmail.uri) Click Here
| .
br
if status === 'verified'
span.
Expand Down Expand Up @@ -80,7 +82,7 @@ block body
div(class='form-group group-' + field.name)
label(
class='col-sm-' + (hasSocialProviders ? 12 : 4),
for='#{field.name}'
for=field.name
) #{field.label}

div(class='col-sm-' + (hasSocialProviders ? 12 : 8))
Expand All @@ -103,15 +105,15 @@ block body
.header &nbsp;
label Easy 1-click login:
if socialProviders.facebook && socialProviders.facebook.enabled
include facebook_login_form.jade
include facebook_login_form
if socialProviders.google && socialProviders.google.enabled
include google_login_form.jade
include google_login_form
if socialProviders.linkedin && socialProviders.linkedin.enabled
include linkedin_login_form.jade
include linkedin_login_form
if socialProviders.github && socialProviders.github.enabled
include github_login_form.jade
include github_login_form

if stormpathConfig.web.verifyEmail.enabled
a.forgot(style="float:left", href="#{stormpathConfig.web.verifyEmail.uri}") Resend Verification Email?
a.forgot(style="float:left", href=stormpathConfig.web.verifyEmail.uri) Resend Verification Email?
if stormpathConfig.web.forgotPassword.enabled
a.forgot(style="float:right", href="#{stormpathConfig.web.forgotPassword.uri}") Forgot Password?
a.forgot(style="float:right", href=stormpathConfig.web.forgotPassword.uri) Forgot Password?
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ block body
div(class='form-group group-' + field.name)
label(
class='col-sm-12',
for='#{field.name}'
for=field.name
) #{field.label}

div(class='col-sm-8')
Expand Down
2 changes: 1 addition & 1 deletion lib/views/register.jade → lib/views/register.pug
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ block body

form.registration-form.form-horizontal.sp-form(method='post', role='form')
each field in formModel.fields
div(form-group='true', class='form-group group-#{field.name}')
div(form-group='true', class='form-group group-' + field.name)
label.col-sm-4 #{field.label}
.col-sm-8
- var value = form ? form[field.name] : '';
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ block vars
- var bodytag = 'login'

block head
meta(http-equiv='refresh' content="5; url=#{app.get('stormpathRedirectUrl')}")
meta(http-equiv='refresh' content='5; url=' + app.get('stormpathRedirectUrl'))

block body
.container.custom-container
Expand Down
5 changes: 3 additions & 2 deletions lib/views/verify.jade → lib/views/verify.pug
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
extends base

block vars
block prepend vars
- var title = 'Resend Account Verification Email?'
- var description = 'Didn\'t receive your account verification email? No worries!'
- var bodytag = 'login'
Expand Down Expand Up @@ -58,4 +58,5 @@ block body
button.login.btn.btn-login.btn-sp-green(type='submit') Submit

if stormpathConfig.web.login.enabled
a.forgot(href="#{stormpathConfig.web.login.uri}") Back to Log In
div.forgot-password-area.col-xs-12
a.forgot(href=stormpathConfig.web.login.uri) Back to Log In
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@
"deep-extend": "^0.4.1",
"express": "^4.13.4",
"forms": "^1.1.4",
"jade": "^1.11.0",
"lodash": "^4.6.1",
"njwt": "^0.3.1",
"parse-iso-duration": "^1.0.0",
"psl": "^1.1.14",
"pug": "^2.0.0-beta11",
"qs": "^6.0.2",
"request": "^2.63.0",
"stormpath": "0.20.x",
Expand Down