I have a requirement like re-authenticate the user on button click.

Consider the user is trying to save the list form and on click of save, a dialog box asks for username and password. Then we should validate the username and password, and if it matches we submit the form to list or else not.

Its a SharePoint online site.

  • How do you plan to validate the credentials? Have you implemented a custom membership provider? You can't just force logout the user, they will lose all their work. – Derek Gusoff Mar 10 '16 at 15:48

One option would be the following:

  1. Inject JavaScript code in the New form. This can be done by editing the list form in SharePoint Designer, or by adding the code in the master page (it would first check the current URL) or by adding a custom action in the list.
  2. The JavaScript would delete all cookies (including authentication cookies). You can use code like the one proposed here: https://stackoverflow.com/a/179514/3439544.

Note: this won't work for all other means you can add an item. For instance won't work for the Quick Edit mode, for addition with client API, etc.

  • Thank you. But once i cleared all the cookies and login again, the form data will reset. – Ashwin Mar 10 '16 at 11:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.