Created
September 26, 2012 21:04
Revisions
-
conradz revised this gist
Oct 5, 2012 . No changes.There are no files selected for viewing
-
conradz revised this gist
Oct 5, 2012 . No changes.There are no files selected for viewing
-
conradz revised this gist
Oct 5, 2012 . No changes.There are no files selected for viewing
-
conradz revised this gist
Oct 5, 2012 . No changes.There are no files selected for viewing
-
conradz revised this gist
Oct 5, 2012 . No changes.There are no files selected for viewing
-
conradz revised this gist
Oct 5, 2012 . No changes.There are no files selected for viewing
-
conradz revised this gist
Oct 5, 2012 . No changes.There are no files selected for viewing
-
conradz revised this gist
Oct 2, 2012 . No changes.There are no files selected for viewing
-
conradz revised this gist
Oct 2, 2012 . No changes.There are no files selected for viewing
-
conradz revised this gist
Sep 26, 2012 . 1 changed file with 2 additions and 8 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -3,28 +3,22 @@ var CREDENTIAL_NAME = "<Your Credential Resource Name>"; var signin = new WinJS.Promise(function (comp, err) { var vault = new Windows.Security.Credentials.PasswordVault(); try { var stored = vault.findAllByResource(CREDENTIAL_NAME); if (stored.length > 0) { stored = stored[0]; // Retrieve the full stored credential stored = vault.retrieve(CREDENTIAL_NAME, stored.userName); return comp({ user: stored.userName, password: stored.password }); } } catch (e) { // Could not find credential } // Prompt the user for a password var opts = new Windows.Security.Credentials.UI.CredentialPickerOptions(); opts.authenticationProtocol = Windows.Security.Credentials.UI.AuthenticationProtocol.basic; -
conradz created this gist
Sep 26, 2012 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,54 @@ var CREDENTIAL_NAME = "<Your Credential Resource Name>"; var signin = new WinJS.Promise(function (comp, err) { var vault = new Windows.Security.Credentials.PasswordVault(); var credential; try { var stored = vault.findAllByResource(CREDENTIAL_NAME); if (stored.length > 0) { stored = stored[0]; // Retrieve the full stored credential stored = vault.retrieve(CREDENTIAL_NAME, stored.userName); credential = { user: stored.userName, password: stored.password }; } } catch (e) { // Could not find credential } if (credential) { // Found saved credential return comp(credential); } // Prompt the user for a password var opts = new Windows.Security.Credentials.UI.CredentialPickerOptions(); opts.authenticationProtocol = Windows.Security.Credentials.UI.AuthenticationProtocol.basic; opts.caption = "<Caption>"; opts.message = "<Message>"; opts.credentialSaveOption = Windows.Security.Credentials.UI.CredentialSaveOption.unselected; opts.callerSavesCredential = true; opts.targetName = "."; var picker = Windows.Security.Credentials.UI.CredentialPicker.pickAsync(opts); picker.then(function (result) { if (result.credential == null) { // User canceled return err(); } if (result.credentialSaveOption === Windows.Security.Credentials.UI.CredentialSaveOption.selected) { vault.add(new Windows.Security.Credentials.PasswordCredential( CREDENTIAL_NAME, result.credentialUserName, result.credentialPassword)); } comp({ user: result.credentialUserName, password: result.credentialPassword }); }, err); })