Skip to content
This repository has been archived by the owner on Mar 16, 2019. It is now read-only.

hawx/persona

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

persona docs

Package for using persona in webapps.

store := persona.NewStore(cookieSecret)
persona := persona.New(store, "http://localhost:8080", []string{"john.doe@example.com"})

http.Handle("/", persona.Switch(SignInHandler, SignedOutHandler))
http.Handle("/secret", persona.Protect(SecretHandler))
http.Handle("/sign-in", persona.SignIn)
http.Handle("/sign-out", persona.SignOut)

then add this to your html,

<script src="http://code.jquery.com/jquery-2.1.1.min.js"></script>
<script src="https://login.persona.org/include.js"></script>

<script>
  function gotAssertion(assertion) {
    // got an assertion, now send it up to the server for verification
    if (assertion !== null) {
      $.ajax({
        type: 'POST',
        url: '/sign-in',
        data: { assertion: assertion },
        success: function(res, status, xhr) {
          window.location.reload();
        },
        error: function(xhr, status, res) {
          alert("sign-in failure" + res);
        }
     });
    }
  };

  jQuery(function($) {
    $('#browserid').click(function() {
      navigator.id.get(gotAssertion);
    });
  });
</script>

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages