Comments (26)
Hi @hunterpp,
Why not? Let's build it together, tell me what you need, and I'll make sure to back it with the proper testing.
from simple_token_authentication.
^^^^ Take note. This guy right here is a proper repo owner.
from simple_token_authentication.
Declaration for a mongoid model is normally this:
class User < ActiveRecord::Base
# this is an AR model
end
class Item
include Mongoid::Document
# this is a Mongoid model
end
So it seems
ActiveRecord::Base.send :include, SimpleTokenAuthentication::ActsAsTokenAuthenticatable
must be changed to:
Mongoid::Document.send :include, SimpleTokenAuthentication::ActsAsTokenAuthenticatable
.
For ActiveSupport::Validations
or similar stuff I do
class Item
include Mongoid::Document
include ActiveModel::Validations
# this is a Mongoid model along with ActiveModel::Validations
end
I hope this helps. Looking forward! :-)
from simple_token_authentication.
a working example is here:
https://github.com/mediatainment/simple_token_authentication
I am sure a simple check "if ActiveRecord::Base defined" elsif Mongoid::Document defined" method extends the functionality of this gem for a lot of users.
from simple_token_authentication.
Hi @mediatainment! I'll be a bit AFK these days, but I'll start building Cucumber scenarii as soon as I can. That was exaclty the help I needed; many many thanks @mediatainment, really.
from simple_token_authentication.
Thank YOU! for making this gem! :-)
from simple_token_authentication.
Is this solved? Now, I'm cloning the repo of @mediatainment. Thanks for these gems! :D
from simple_token_authentication.
Hi @Angelmmiguel,
Nope, it's work in progress, but your feedback about the @mediatainment fork would be welcome, particularly if your setup mixes Mongoid and ActiveRecord!
from simple_token_authentication.
Hi @gonzalo-bulnes!
I'm new on ruby on rails, but I'll try it ;). Thanks!
from simple_token_authentication.
it works for me like a charm...
from simple_token_authentication.
Hi @mediatainment, all,
I'm struggling with Gemfile-related issues in the testing environment, which are not directly related to Mongoid but which are preventing me from writing a Mongoid version of the existing Cucumber scenarii. Just for you know that I'm not forgetting about bringing Mongoid support to the gem :P
The main point is that supporting Mongoid supposes to make sure the gem features will keep working with it in the future, and that's why the test suite is made for. That being said, it occurs that I haven't managed to be really free to use an arbitrary version of Rails when I build the dummy test app, and since Rails 4 get's installed by default, the Mongoid setup fails. I'm looking for solutions to that (which may be more related to Cucumber than they are to Mongoid) and in case someone had time to take a look at it, I could make make a detailed description of the issue, which is a bit off-topic here. That's one point.
Another point, more mongoistic than the previous one: does any of you work with both Mongoid and ActiveRecord in the same application? All the forks I've seen replace one by the another. I'm not familiar with Mongoid, but I don't see any reason why they could not live together. In order to prepare such a testing scenario, any feedback on that would be greatly appreciated.
Thanks for keeping an eye on this issue, best regards!
from simple_token_authentication.
I can only speak for me. No, I do not use these ORM-Adapters simultaneously. All my apps are using one DB per usage. Postgres, MySQL or Mondoid.
from simple_token_authentication.
@gonzalo-bulnes ... first of all thanks for the gem... secondly is the mongoid support near ?
also put the reference to the off topic issue you have with mongoid and cucumber... which i might work on in my free time.
from simple_token_authentication.
I am trying to use @mediatainment fork with no success.
lib/simple_token_authentication/acts_as_token_authenticatable.rb:33:in `<top (required)>': uninitialized constant Mongoid (NameError)
from simple_token_authentication.
@prem-prakash are you sure you have installed mongoid correctly?
try
require 'mongoid'
from simple_token_authentication.
I am using setup described here: http://mongoid.org/en/mongoid/docs/installation.html
It don't use
require 'mongoid'
In my Gemfile I have
gem 'rails', '4.0.3'
gem 'mongoid', github: 'mongoid/mongoid'
gem 'simple_token_authentication', github: 'mediatainment/simple_token_authentication'
Also my models are using mongoid with no problem.
from simple_token_authentication.
Adding
require 'mongoid'
to beginning of lib//simple_token_authentication/acts_as_token_authenticatable.rb
make it works
from simple_token_authentication.
Hi @prem-prakash,
Thanks for the feedback, I wonder what in your setup is different from the @mediatainment (and others) setup.
from simple_token_authentication.
Hi @gonzalo-bulnes and @mediatainment
As I can see it is a dependency problem, which can be solved at gemspec file.
I will make a pull request.
from simple_token_authentication.
Any update on this?
from simple_token_authentication.
@mediatainment Fork works fine for me...
from simple_token_authentication.
Hi @muichkine,
there are little news in #97, and the @mediatainment fork is a good way to go in the meanwhile : )
Regards!
from simple_token_authentication.
The @mediatainment fork doesn't work here. As soon as I call acts_as_token_authentication_handler_for User
in my controller, I can't start the server and get the following error:
muichkine@ubuntu:~/src/white$ rails s
=> Booting Puma
=> Rails 4.1.6 application starting in development on http://0.0.0.0:3000
=> Run `rails server -h` for more startup options
=> Notice: server is listening on all interfaces (0.0.0.0). Consider using 127.0.0.1 (--binding option)
=> Ctrl-C to shutdown server
Exiting
/home/muichkine/src/white/app/models/user.rb:18:in `<class:User>': undefined method `devise' for User:Class (NoMethodError)
from /home/muichkine/src/white/app/models/user.rb:1:in `<top (required)>'
As soon as I remove the call from the controller, my devise codes go back to normal. :)
from simple_token_authentication.
Hi @mediatainment, (and anyone interested!)
If you have a moment, could you please take a look and give a try to this?
# Gemfile
# ...
gem 'simple_token_authentication',
git: 'https://github.com/gonzalo-bulnes/simple_token_authentication.git',
branch: 'spike-add-mongoid-support-using-adapter'
# ...
Thanks, regards!
from simple_token_authentication.
Hello @hunterpp, @austinpray, @mediatainment, @Angelmmiguel, @artmees, @prem-prakash and @muichkine!
I just released v1.6.0 which add support for Mongoid. I want to thank all of you for your comments and observations. Also for your patience which has been a great motivator to perform some deep refactoring (#104). The result is a speedy test suite which, I hope, is also easier for everyone to extend and will be beneficial in other scenarios. Here's 🎁 Mongoid support, looking forward for new ideas ; )
I checked the details with Rails 3.2.19 + Mongoid 3.1.6 and Rails 4.1.6 + Mongoid 4.0.0, both with and without ActiveRecord. Please, don't hesitate to raise any issue I could have missed, I'm sure most of you know more about Mongoid than I do.
Regards!
from simple_token_authentication.
🍻
from simple_token_authentication.
Related Issues (20)
- Is that gem work with API? HOT 4
- Mongoid does support Rails 6 now/soon HOT 3
- uninitialized constant SimpleTokenAuthentication::Adapters HOT 5
- Gem doesn't protect data?
- separate registration and signin so no token is received by client when registering
- how to auth 2 different models with same alias ?
- acts_as_token_authenticatable causes a DEPRECATION WARNING
- Q: How to do not require user_email? HOT 1
- Getting 401 unauthorized Error
- Where should I store the token on the frontend? HOT 3
- Entering fallback! with token_correct? set to true HOT 1
- 406 Errors on Authentication Test
- The mongoid range of supported versions needs review
- Discussions are set up! HOT 1
- Identify support requests, feature requests in issues and pull requests HOT 1
- Update the contributing guidelines to mention Discussions etc.
- Add (actual) example of maintenance trade-off for discussion HOT 1
- split responsibilities of acts_as_token_authentication_handler_for method HOT 1
- Rails 7 support? HOT 30
- Can we use JWT as a user token?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from simple_token_authentication.