Wednesday, 12 April 2017

keystone.js Currently logged in user

I'm new to Keystone, but have been trying all day to find the currently logged in user name but I'm not clear how to do this.

If I take the index view from keystone for example


<div class="container">
    <div class="jumbotron"><img src="/images/logo.svg" width="160">
        <h1>Welcome</h1>
        <p>This is your new <a href='http://keystonejs.com' target='_blank'>KeystoneJS</a> website.</p>
        <p>
            It includes the latest versions of
            <a href='http://getbootstrap.com/' target='_blank'>Bootstrap</a>
            and <a href='http://www.jquery.com/' target='_blank'>jQuery</a>.
        </p>
        <p>Visit the <a href='http://keystonejs.com/guide' target='_blank'>Getting Started</a> guide to learn how to customise it.</p>
        <hr>
        <p>We have created a default Admin user for you with the email <strong>masterofimps@yahoo.co.uk</strong> and the password <strong>admin</strong>.</p>
        <p><a href="/keystone/signin" style="margin-right: 10px" class="btn btn-lg btn-primary">Sign in</a> to use the Admin UI.</p>
        <hr>
        <p>
            Remember to <a href='https://github.com/keystonejs/keystone' target='_blank'>Star KeystoneJS on GitHub</a> and
            <a href='https://twitter.com/keystonejs' target='_blank'>follow @keystonejs</a> on twitter for updates.
        </p>
    </div>
</div>

and I want to add the user name to the view code somthing like

<h1>Welcome Tim</h1>

I have tried

<h1>Welcome </h1>
<h1>Welcome </h1>
<h1>Welcome </h1> (using an Express request)

But to no avail. How do I find the user name from the User model? Do I have to define something else in the ..\routes\views first?

If anyone could help with an example or pointer in the right direction, Id be very grateful indeed!



via masterofimps

No comments:

Post a Comment