Hide the download link for not authenticated user

hadi tag asked on February 17, 2015 18:11

hi

how to Hide or redirect to login page, the download link (If the user has a direct link) for the user that is not authenticated.

please help

Recent Answers


Jan Hermann answered on February 18, 2015 07:43

Hello,

how do you want to hid the link when the user has it already? If you want to hide a link on your page, you can use macros like this:

{%CurrentUser.IsAuthenticated?"<a href='link'>link</a>":""%}

If the user has the link already you would need to apply some file permissions, but this depends on the type of the file. For instance for the CMS.File, you can simply set page permissions on the Security tab of that file.

Best regards,
Jan Hermann

0 votesVote for this answer Mark as a Correct answer

hadi tag answered on February 18, 2015 09:25 (last edited on February 18, 2015 09:28)

thanks

but i want after that user enter direct url link in his browser,

kentico check user authentication and then allow to use

i want a solution for this problem....

0 votesVote for this answer Mark as a Correct answer

Jan Hermann answered on February 19, 2015 07:47

Hello,

in this case you need to follow the second approach I have described. Let's say you have link like http://yoursite/files/some_file, then you simply go to the files -> some_file location in your content tree, switch to Properties -> Security section and set the Requires authentication property to Yes. A visitor with direct link will be redirected to your logon page and after they sign in Kentico offers given file for download.

Best regards,
Jan Hermann

1 votesVote for this answer Mark as a Correct answer

Jagdish Narkar answered on February 19, 2015 23:29

That's the perfect approach. I have been doing the same.

0 votesVote for this answer Mark as a Correct answer

Subhajit Biswas answered on August 17, 2015 16:24

What if the file I want to restrict is in Media Library?

Can anyone help?

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.