Prompt auth (request.user) for password again before saving to model in Django admin












0















I'd like to prompt an auth user in Django admin to enter their password to verify it matches before saving a model (using save_model override). The reason I'd like to do this is because my client is currently dealing with a staff that can sometimes be 'forgetful' and/or they are just so busy they can't take the time to logout of someone else's admin account, and logging into their own, before adding/editing an object.



I have an 'added_by' field associated with the model, and the field is editable by way of dropdown in the actual model form in admin. A list of auth users is available, and one could be different from whoever is currently logged in. If the latter is the case, is there a way to accomplish my goal of prompting for either the current auth user password, and upon an incorrect password, forcing them to logout and login before creating/editing the object? Or better, yet a way to prompt for whoever they choose in the dropdown for that auth user's password to verify?



Lastly, is there is a way, if I add a 'modified_by' to said model, to have that show whoever modified the order, but still keep the original 'added_by' associated with the applicable auth user?



I thought this would be something simple to do, but can't find any documentation or threads on this. Thanks in advance.










share|improve this question

























  • I would something like this. Add a popup in change_form html to enter password. Override submit button click handler in frontend side. Show popup and after enter passowrd, submit form. In backend check for password in the django form. Hope you got what i mean

    – itzMEonTV
    Nov 23 '18 at 5:53













  • Yea, I had a similar thought process, but couldn't quite work out in my mind how I would verify the password on the backend. Can you shed some light or provide an example on how to do that please?

    – Dev
    Nov 23 '18 at 5:56






  • 1





    Any user obj, you can check using user_obj.check_password("password")

    – itzMEonTV
    Nov 23 '18 at 5:58













  • Hmmm that sounds promising, but I had problems with this earlier. How do I get the user obj from within a model class, especially when it's a auth user that's not currently logged in? I think I might have access to the current auth user model through the save_model function I wrote that takes in request as an argument...

    – Dev
    Nov 23 '18 at 7:07













  • Ok, I figured out how to iterate through the different auth users, by importing and using the get_user_model() method. Is that what you had in mind?

    – Dev
    Nov 23 '18 at 8:04
















0















I'd like to prompt an auth user in Django admin to enter their password to verify it matches before saving a model (using save_model override). The reason I'd like to do this is because my client is currently dealing with a staff that can sometimes be 'forgetful' and/or they are just so busy they can't take the time to logout of someone else's admin account, and logging into their own, before adding/editing an object.



I have an 'added_by' field associated with the model, and the field is editable by way of dropdown in the actual model form in admin. A list of auth users is available, and one could be different from whoever is currently logged in. If the latter is the case, is there a way to accomplish my goal of prompting for either the current auth user password, and upon an incorrect password, forcing them to logout and login before creating/editing the object? Or better, yet a way to prompt for whoever they choose in the dropdown for that auth user's password to verify?



Lastly, is there is a way, if I add a 'modified_by' to said model, to have that show whoever modified the order, but still keep the original 'added_by' associated with the applicable auth user?



I thought this would be something simple to do, but can't find any documentation or threads on this. Thanks in advance.










share|improve this question

























  • I would something like this. Add a popup in change_form html to enter password. Override submit button click handler in frontend side. Show popup and after enter passowrd, submit form. In backend check for password in the django form. Hope you got what i mean

    – itzMEonTV
    Nov 23 '18 at 5:53













  • Yea, I had a similar thought process, but couldn't quite work out in my mind how I would verify the password on the backend. Can you shed some light or provide an example on how to do that please?

    – Dev
    Nov 23 '18 at 5:56






  • 1





    Any user obj, you can check using user_obj.check_password("password")

    – itzMEonTV
    Nov 23 '18 at 5:58













  • Hmmm that sounds promising, but I had problems with this earlier. How do I get the user obj from within a model class, especially when it's a auth user that's not currently logged in? I think I might have access to the current auth user model through the save_model function I wrote that takes in request as an argument...

    – Dev
    Nov 23 '18 at 7:07













  • Ok, I figured out how to iterate through the different auth users, by importing and using the get_user_model() method. Is that what you had in mind?

    – Dev
    Nov 23 '18 at 8:04














0












0








0








I'd like to prompt an auth user in Django admin to enter their password to verify it matches before saving a model (using save_model override). The reason I'd like to do this is because my client is currently dealing with a staff that can sometimes be 'forgetful' and/or they are just so busy they can't take the time to logout of someone else's admin account, and logging into their own, before adding/editing an object.



I have an 'added_by' field associated with the model, and the field is editable by way of dropdown in the actual model form in admin. A list of auth users is available, and one could be different from whoever is currently logged in. If the latter is the case, is there a way to accomplish my goal of prompting for either the current auth user password, and upon an incorrect password, forcing them to logout and login before creating/editing the object? Or better, yet a way to prompt for whoever they choose in the dropdown for that auth user's password to verify?



Lastly, is there is a way, if I add a 'modified_by' to said model, to have that show whoever modified the order, but still keep the original 'added_by' associated with the applicable auth user?



I thought this would be something simple to do, but can't find any documentation or threads on this. Thanks in advance.










share|improve this question
















I'd like to prompt an auth user in Django admin to enter their password to verify it matches before saving a model (using save_model override). The reason I'd like to do this is because my client is currently dealing with a staff that can sometimes be 'forgetful' and/or they are just so busy they can't take the time to logout of someone else's admin account, and logging into their own, before adding/editing an object.



I have an 'added_by' field associated with the model, and the field is editable by way of dropdown in the actual model form in admin. A list of auth users is available, and one could be different from whoever is currently logged in. If the latter is the case, is there a way to accomplish my goal of prompting for either the current auth user password, and upon an incorrect password, forcing them to logout and login before creating/editing the object? Or better, yet a way to prompt for whoever they choose in the dropdown for that auth user's password to verify?



Lastly, is there is a way, if I add a 'modified_by' to said model, to have that show whoever modified the order, but still keep the original 'added_by' associated with the applicable auth user?



I thought this would be something simple to do, but can't find any documentation or threads on this. Thanks in advance.







django django-models django-forms django-templates django-admin






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 23 '18 at 7:33







Dev

















asked Nov 23 '18 at 4:58









DevDev

387




387













  • I would something like this. Add a popup in change_form html to enter password. Override submit button click handler in frontend side. Show popup and after enter passowrd, submit form. In backend check for password in the django form. Hope you got what i mean

    – itzMEonTV
    Nov 23 '18 at 5:53













  • Yea, I had a similar thought process, but couldn't quite work out in my mind how I would verify the password on the backend. Can you shed some light or provide an example on how to do that please?

    – Dev
    Nov 23 '18 at 5:56






  • 1





    Any user obj, you can check using user_obj.check_password("password")

    – itzMEonTV
    Nov 23 '18 at 5:58













  • Hmmm that sounds promising, but I had problems with this earlier. How do I get the user obj from within a model class, especially when it's a auth user that's not currently logged in? I think I might have access to the current auth user model through the save_model function I wrote that takes in request as an argument...

    – Dev
    Nov 23 '18 at 7:07













  • Ok, I figured out how to iterate through the different auth users, by importing and using the get_user_model() method. Is that what you had in mind?

    – Dev
    Nov 23 '18 at 8:04



















  • I would something like this. Add a popup in change_form html to enter password. Override submit button click handler in frontend side. Show popup and after enter passowrd, submit form. In backend check for password in the django form. Hope you got what i mean

    – itzMEonTV
    Nov 23 '18 at 5:53













  • Yea, I had a similar thought process, but couldn't quite work out in my mind how I would verify the password on the backend. Can you shed some light or provide an example on how to do that please?

    – Dev
    Nov 23 '18 at 5:56






  • 1





    Any user obj, you can check using user_obj.check_password("password")

    – itzMEonTV
    Nov 23 '18 at 5:58













  • Hmmm that sounds promising, but I had problems with this earlier. How do I get the user obj from within a model class, especially when it's a auth user that's not currently logged in? I think I might have access to the current auth user model through the save_model function I wrote that takes in request as an argument...

    – Dev
    Nov 23 '18 at 7:07













  • Ok, I figured out how to iterate through the different auth users, by importing and using the get_user_model() method. Is that what you had in mind?

    – Dev
    Nov 23 '18 at 8:04

















I would something like this. Add a popup in change_form html to enter password. Override submit button click handler in frontend side. Show popup and after enter passowrd, submit form. In backend check for password in the django form. Hope you got what i mean

– itzMEonTV
Nov 23 '18 at 5:53







I would something like this. Add a popup in change_form html to enter password. Override submit button click handler in frontend side. Show popup and after enter passowrd, submit form. In backend check for password in the django form. Hope you got what i mean

– itzMEonTV
Nov 23 '18 at 5:53















Yea, I had a similar thought process, but couldn't quite work out in my mind how I would verify the password on the backend. Can you shed some light or provide an example on how to do that please?

– Dev
Nov 23 '18 at 5:56





Yea, I had a similar thought process, but couldn't quite work out in my mind how I would verify the password on the backend. Can you shed some light or provide an example on how to do that please?

– Dev
Nov 23 '18 at 5:56




1




1





Any user obj, you can check using user_obj.check_password("password")

– itzMEonTV
Nov 23 '18 at 5:58







Any user obj, you can check using user_obj.check_password("password")

– itzMEonTV
Nov 23 '18 at 5:58















Hmmm that sounds promising, but I had problems with this earlier. How do I get the user obj from within a model class, especially when it's a auth user that's not currently logged in? I think I might have access to the current auth user model through the save_model function I wrote that takes in request as an argument...

– Dev
Nov 23 '18 at 7:07







Hmmm that sounds promising, but I had problems with this earlier. How do I get the user obj from within a model class, especially when it's a auth user that's not currently logged in? I think I might have access to the current auth user model through the save_model function I wrote that takes in request as an argument...

– Dev
Nov 23 '18 at 7:07















Ok, I figured out how to iterate through the different auth users, by importing and using the get_user_model() method. Is that what you had in mind?

– Dev
Nov 23 '18 at 8:04





Ok, I figured out how to iterate through the different auth users, by importing and using the get_user_model() method. Is that what you had in mind?

– Dev
Nov 23 '18 at 8:04












0






active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53440855%2fprompt-auth-request-user-for-password-again-before-saving-to-model-in-django-a%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes
















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53440855%2fprompt-auth-request-user-for-password-again-before-saving-to-model-in-django-a%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

404 Error Contact Form 7 ajax form submitting

How to know if a Active Directory user can login interactively

TypeError: fit_transform() missing 1 required positional argument: 'X'