-
Notifications
You must be signed in to change notification settings - Fork 26
Devise and Database.com
Add [cs_api][accounts] field to config.yml file.(See config.example.yml file)
Run migration with rake db:migrate
Run Rails server and connect.
Account model is introduced to wrap all API requests concened with accounts. I referenced cs-api source directly while working.
Examples are
account = Accoune.new(user) # or
account = user.account
account.authenticate(password)
account.create
account.reset_password
Account.find(username)
You can see tests from account_spec.rb file. VCR is awesome!!!
Added access_token sfdc_username profile_pic accountid attributes to users table.
This job was not easy. The big principal is 'API call first, and then devise'.
User signing-up occurs with 2 ways, from email authentication and from third-party. For Email authentication added @user.create_account to Users::RegistrationsController, and for third-party authenticaiton added user.create_account to AuthenticationsController.
Users::SessionsController is responsible for login. Added authenticate_account filter before create action. If API call success, it updates access_token.
User account can be searched by Account.find method.
I rewrote Users::PasswordsController since we did not need to send email notification with devise. With reset API call, reset_password_token(or passcode) is generated and notification email is sent to user by Salesforce.(right?) I assumed that reset password url in notification email sent by Salesforce has rest_password_token and username parameters. So url is something like http://HOSTNAME/resource/password/edit?reset_password_token=abcdef&username=testuser' If this usl is clicked, it shows edit form including rest_password_token and username as hdden field, and they are used to update API.
-
ApiModel.requestmethod is added to handle requests that need authentication. - And some refactorings are added.