Rail Add Password on Uploaded PDF file - ruby-on-rails

I have an Rails application where the user can upload a PDF. The application will add a password automatically(the password will be generated using the user's data) then will save it to AWS S3. So, when the user opens that PDF, the PDF would ask for the password.
Right now I am able to upload the PDF without adding password and it is working. My problem is adding password on it automatically.
On the same application, I also used Prawn since I have separate feature where the system will generate the PDF(not upload by the user) and I can add password into it.
P.S. I also need to add password if the user upload an image file. I just want to ask if there is a way I can add password to uploaded image file OR I need to convert it to PDF?
Thanks for the help!

Related

Not able to login user with same credentials as imported database as it uses encrypt fields such as email

Due to some data related issues,I imported dev database to my local database that is running via docker however I am not able to login a user with same credentials that are working on dev server/database. I noticed that fields like email etc are using rails encrypt database field.
I am not able to login user with same username password ,if some one knows what might be causing it and a solution to it,that would be wonderful. Thanks in advance.

Swift-Application with Login and offlinemodus

maybe this is for many of you a very simple question but I need some tipps.
I will create a app, which can be used online and offline. At the webserver is symfony with the FOSUserBundle used. Login and working in the webbrowser works very well.
My aim is:
Start the app on a iOS-Device. When the user are not be logged in, then the loginform from the application would be viewed. The login should be able to remember.
The app will after the login synchronize the data from the webserver with the device-database.
When the user didn't have a mobileconnection and he didn't log himself out, then the application should show the screen with his data. I mean this like the messenger from facebook.
All views on the mobiledevice are completely developed with swift. There is not a webview from the webserver.
Please can you give me for this a little tip, for what I have to search?
I search for FOSOAuthServerBundle but I dont think that I am on the right way.
What I did for my app with symfony as a backend:
having a controller in symfony which receives the login data from the app and check if the username and password are correct. After this confirmation, the controller is answering with the data I need in the app (json format)
in the app I save the username and password (I need this because if there is no connection to the internet I need to check the login against something).
It means, that every time the user logged in successful with internet connection, the username and password are saved.
in the app I save the json-response with key-archiving into documents folder.
the app always loads the json-file from documents folder, after the user logged in successfully.
So with internet connection:
1) check username and password against the FOSUserbundle in Symfony
2) save the username and password in the app
3) save the response as file into documents folder
4) let the app load its content from that folder
Without internet connection
1) check username and password against the credentials stored in the app from the last successful login with internet connection
2) let the app load its content from the documents folder

Twitter Omniauth Profile Picture Broken after changed on Twitter

I have twitter ommiauth as my user model and I pull in when they register a link of their profile picture via the hash auth.info.image. Iv noticed some are now breaking where the user has updated their profile picture on Twitter.
I noticed there is a part of the hash that gets the image over https (profile_image_url_https) in the raw_info section. Details here https://github.com/arunagw/omniauth-twitter. is this the best practice to link to so it doesnt happen again?
My issue is that I may have a user that logs in once and leaves a comment but then their profile changes and it breaks on the site.
Is there another way I should be implementing this?
Any information would be much appreciated.
If you are saving the twitter image url when a user creates an account or logs in via oAuth and not checking whether it has changed when attempting to display it this would be expected. The only thing I can think of to fix disappearing links would be to test the data with an http or url call and replace it with a placeholder image or ping the API to retrieve the updated image.

Rails custom reset password email

I have a project that is built on LocomtiveCMS, which already has reset password functionality built in. However, the reset password email it currently sends has just a basic skeleton wording.
How do I make a custom message to use in the email sent out for resetting a password?
Inside your main app, all you have to do is to add a new file at this location: /app/views/locomotive/devise_mailer/reset_password_instructions.html.haml.
After a restart of your server, Devise should use this file as the new template for the reset password instructions.
We did that for LocomotiveHosting.com (which is built on top on the LocomotiveCMS engine) and it works well.
Thanks!
Did

With Paperclip, how could I create a attachment object using a URL?

Basically, because Omniauth retrieves URL's of the user's profile picture for say, Facebook, I need to find a way to generate attach that URL as a file for the user.

Resources