This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// If the request was unauthorized, add the WWW-Authenticate header | |
// to the response. | |
private static void OnApplicationEndRequest(object sender, EventArgs e) | |
{ | |
var response = HttpContext.Current.Response; | |
// see if the request sent an X-Requested-With header (Non-Browser request - | |
// used by jQuery and Angular implementations to prevent the browser from | |
// presenting the default Login dialog) | |
var request = HttpContext.Current.Request; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* $http interceptor. | |
* On 401 response - it stores the request and broadcasts 'event:auth-loginRequired'. | |
*/ | |
angular.module('app').config(function ($httpProvider) { | |
$httpProvider.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest'; | |
var interceptor = ['$rootScope', '$q', function (scope, $q) { | |
function success(response) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class="modal h1"> | |
<div class="h2 container alert-info modal-body" data-backdrop="static"> | |
Login<br /><br /> | |
<div class="alert-danger">{{error}}</div> | |
<ng-form class="form-horizontal"> | |
Username: | |
<input class="form-control" ng-model="username" /> | |
Password: | |
<input class="form-control" type="password" ng-model="password" /> | |
<br /> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
angular.module('app').directive('loginDialog', function () { | |
return { | |
templateUrl: 'app/templates/loginDialog.html', | |
restrict: 'E', | |
replace: true, | |
controller: 'CredentialsController', | |
link: function (scope, element, attributes, controller) { | |
scope.$on('event:auth-loginRequired', function () { | |
console.log("got login event"); | |
element.modal('show'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html ng-app="app"> | |
<head> | |
<title>Sample Angular Client for Basic Authentication</title> | |
<meta name="description" content=""> | |
<meta name="viewport" content="width=device-width, initial-scale=1"> | |
<!-- Place favicon.ico and apple-touch-icon.png in the root directory --> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function CredentialsController($scope, $http, $cookieStore, Base64) { | |
$scope.login = function (userName, password) { | |
var encodedUserNameAndPassword = Base64.encode(userName + ':' + password); | |
$http.defaults.headers.common['Authorization'] = 'Basic ' + encodedUserNameAndPassword; | |
$cookieStore.put('basicCredentials', encodedUserNameAndPassword); | |
$http.get(baseUrl + '/Values') | |
.success(function() { | |
$scope.$broadcast('event:auth-loginConfirmed'); | |
$scope.password = ''; | |
}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var baseUrl = 'http://localhost:49587/api'; | |
angular.module('app').controller('SampleController', function ($scope, $http, $cookieStore, Base64) { | |
$scope.refreshData = function () { | |
//Used to display the data | |
if ($cookieStore.get('basicCredentials')) | |
{ | |
$http.defaults.headers.common['Authorization'] = 'Basic ' + $cookieStore.get('basicCredentials'); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE root [ | |
<!ENTITY Aacute "Á"> | |
<!ENTITY aacute "á"> | |
<!ENTITY Abreve "Ă"> | |
<!ENTITY abreve "ă"> | |
<!ENTITY ac "∾"> | |
<!ENTITY acd "∿"> | |
<!ENTITY Acirc "Â"> | |
<!ENTITY acirc "â"> | |
<!ENTITY acute "´"> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Settings page for Pebble</title> | |
<meta charset="utf-8" /> | |
<link href="../Content/bootstrap.min.css" rel="stylesheet" /> | |
<link href="../Content/Site.css" rel="stylesheet" /> | |
<script src="../Scripts/bootstrap.min.js"></script> | |
</head> | |
<body> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for (int i = 1; i <= 100; i++) | |
{ | |
if ((i % 3 == 0) && (i % 5 == 0)) | |
{ | |
Debug.WriteLine("FizzBuzz"); | |
} | |
else if (i % 3 == 0) | |
{ | |
Debug.WriteLine("Fizz"); | |
} |