Skip to content

Instantly share code, notes, and snippets.

@b-tiwari
b-tiwari / AppEvents.ts
Last active January 24, 2018 20:28
TS String Enums
//String Enums, supported TS 2.4 onwards
export enum AppEventsEnum {
ReachedHome = "reached-home",
ReachedWork = "reached-work",
TurnOnLight = "turnOn-light",
TurnOffLight = "turnOff-light",
PublishArticle = "publish-article"
}
@b-tiwari
b-tiwari / ionicEventsExample.ts
Last active January 24, 2018 20:30
Ionic Events
import { Component } from '@angular/core';
import { Events } from 'ionic-angular';
import { AppEventsEnum } from '../Enums/AppEvents';
@Component({
selector: 'publisher',
templateUrl: 'publisher.html'
})
export class Publisher {
@b-tiwari
b-tiwari / _loginPartial.cshtml
Last active November 6, 2017 04:50
_loginPartial.cshtml - Claims based identity in MVC
@using Microsoft.AspNet.Identity
@if (Request.IsAuthenticated)
{
    using (Html.BeginForm("LogOff", "Account", FormMethod.Post, new { id = "logoutForm", @class = "navbar-right" }))
    {
    @Html.AntiForgeryToken()
    <ul class="nav navbar-nav navbar-right">
        <li>
            @Html.ActionLink("Hello " + @appUserClaims.GivenName + "!", "Index", "Manage", routeValues: null, htmlAttributes: new { title = "Manage" })
@b-tiwari
b-tiwari / web.config.xml
Created November 6, 2017 04:43
web.config.xml - Claims based identity in MVC
...
...
<system.web.webPages.razor>
    <host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=5.2.2.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
    <strong><pages pageBaseType="csWinAuthWClaims.Views.AppCommonViewUtils"></strong>
      <namespaces>
        <add namespace="System.Web.Mvc" />
        <add namespace="System.Web.Mvc.Ajax" />
        <add namespace="System.Web.Mvc.Html" />
        <add namespace="System.Web.Optimization"/>
@b-tiwari
b-tiwari / AppCommonViewUtils.cs
Created November 6, 2017 04:37
AppCommonViewUtils.cs - Claims based identity in MVC
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Claims;
using System.Web;
using System.Web.Mvc;
namespace csWinAuthWClaims.Views
{
@b-tiwari
b-tiwari / AppUserPrincipalClaims.cs
Created November 6, 2017 04:30
AppUserPrincipalClaims.cs - Claims based identity in ASP.Net MVC
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Claims;
using System.Web;
namespace csWinAuthWClaims.Views
{
    public class AppUserPrincipalClaims : ClaimsPrincipal
@b-tiwari
b-tiwari / HomeController.cs
Created November 6, 2017 04:23
Claims based identity in MVC (HomeController.cs)
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using csWinAuthWClaims.Attributes;
namespace csWinAuthWClaims.Controllers
{
    [AppClaimsAuthorize(ClaimType="myAppUserRole", ClaimValue="myAppAdmin")]
@b-tiwari
b-tiwari / component.html
Created September 6, 2017 01:59
ngIf example
<div *ngIf="albums.length > 0">
<span> User Albums </span>
...
</div>
{
"id":"123",
"name":"Test User Two",
"first_name":"Test",
"middle_name":"User",
"last_name":"Two",
"picture":{
"data":{
"is_silhouette":true,
"url":454353"
@b-tiwari
b-tiwari / karma.conf.js
Created June 5, 2017 00:56
Angular 2/4 from scratch - updated karma.conf.js
// Karma configuration
// Generated on Sun Jun 04 2017 19:05:24 GMT-0500 (Central Daylight Time)
module.exports = function(config) {
config.set({
// base path that will be used to resolve all patterns (eg. files, exclude)
basePath: '',
// frameworks to use
// available frameworks: https://npmjs.org/browse/keyword/karma-adapter