Added Html helpers for CurrentUser for use in Razor views #896

Merged
merged 2 commits into from Jan 9, 2013

Conversation

Projects
None yet
3 participants
Member

jchannon commented Jan 8, 2013

In the view you can now call

@Html.IsAuthenticated and @Html.CurrentUser

@grumpydev grumpydev commented on an outdated diff Jan 8, 2013

src/Nancy.ViewEngines.Razor/HtmlHelpers.cs
@@ -102,5 +102,26 @@ public string CurrentLocale
{
get { return this.RenderContext.Context.Culture.Name; }
}
+
+ /// <summary>
+ /// Returns current authenticated user name
+ /// </summary>
+ public string CurrentUser
+ {
+ get
+ {
+ return this.RenderContext.Context.CurrentUser == null
@grumpydev

grumpydev Jan 8, 2013

Owner

I think this should just return the current user, not the username string.

@thecodejunkie thecodejunkie commented on the diff Jan 8, 2013

src/Nancy.ViewEngines.Razor/HtmlHelpers.cs
@@ -3,6 +3,7 @@
using System;
using System.IO;
using System.Linq.Expressions;
+ using Nancy.Security;
@thecodejunkie

thecodejunkie Jan 8, 2013

Owner

Good man! =)

@jchannon

jchannon Jan 8, 2013

Member

I'm nervous now

@thecodejunkie thecodejunkie added a commit that referenced this pull request Jan 9, 2013

@thecodejunkie thecodejunkie Merge pull request #896 from jchannon/CurrentUserViewItem
Added Html helpers for CurrentUser for use in Razor views
d35433a

@thecodejunkie thecodejunkie merged commit d35433a into NancyFx:master Jan 9, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment