devise

Why does current_user session become nil when updating a user?

瘦欲@ 提交于 2020-06-25 04:00:10
问题 I'm using Devise and CanCan for user authentication and administrating roles restricting access to parts of my Rails 4 app for certain users. I've run into some problems with updating a user. The update works fine and the user object in the db get updated as it should, but my user session is lost on the following redirect_to my user show action. current_user becomes nil which means that CanCan restricts the access to the user show action. Why does current_user become nil after update, when

Ruby on Rails: bad username / password? (535 Auth failed)

不打扰是莪最后的温柔 提交于 2020-05-29 03:53:10
问题 I just finished my ruby foundations coursework at Bloc and I'm starting to bury my head into rails development. Things were going smooth until I hit this snag with devise and confirmation emails. I tried googling and looking around at some other questions but couldn't really find any that gave me anything that I could pull from and apply to my situation. I'm receiving the following error when signing up for an account. Net::SMTPAuthenticationError in Devise::RegistrationsController#create 535

Heroku/Rails/Devise: The change you wanted was rejected

烈酒焚心 提交于 2020-05-13 04:12:06
问题 I'm having a problem with my Rails 4.2 app running the latest version of Devise on Heroku. I'm going to preface this by stating that I have not pushed any code changes to production in quite some time and that this issue only started recently. When I go to log in, I receive an error saying "The change you wanted was rejected." When I view the logs, I can see that it's a problem with the CSRF token. 2015-04-04T19:52:22.430533+00:00 app[web.1]: Started POST "/users/sign_in" for 76.119.72.58 at

Rails pass request.subdomain into a custom Devise mailer layout

谁说胖子不能爱 提交于 2020-05-10 14:15:07
问题 I need to adapt the forgot password instructions to handle a subdomain. I have followed the instructions on the devise site to override the mailer, controller and add a subdomain helper etc. as listed: controllers/password_controller.rb class PasswordsController < Devise::PasswordsController def create @subdomain = request.subdomain super end end routes.rb devise_for :users, controllers: { passwords: 'passwords' } devise.rb config.mailer = "UserMailer" mailers/user_mailer.rb class UserMailer

Rails pass request.subdomain into a custom Devise mailer layout

自古美人都是妖i 提交于 2020-05-10 14:15:04
问题 I need to adapt the forgot password instructions to handle a subdomain. I have followed the instructions on the devise site to override the mailer, controller and add a subdomain helper etc. as listed: controllers/password_controller.rb class PasswordsController < Devise::PasswordsController def create @subdomain = request.subdomain super end end routes.rb devise_for :users, controllers: { passwords: 'passwords' } devise.rb config.mailer = "UserMailer" mailers/user_mailer.rb class UserMailer

Windows API 搭建OpenGL窗口

旧城冷巷雨未停 提交于 2020-04-28 23:22:26
步骤: 1、创建windows窗口,得到窗口句柄hwnd 2、获取该窗口的设备环境hDC(当然也可以获取其他的设备环境,但我们一般是在创建的窗口上绘制) 3、创建OpenGL绘制环境RC,这个只能从hDC创建 4、将hDC和RC绑定到当前的线程 注:RC表示OpenGL的绘制环境,所有的OpenGL命令都会在RC这个绘制环境中作用,所以必须在RC绑定到当前线程之后才能调用OpenGL命令,否则运行出错,内存访问错误。   一般的笔刷绘制,在hDC下即可。 封装的窗口类如下:   GLWindow.h #pragma once #include <windows.h> #include <GL/glew.h> #include <iostream> class GLContext { public : GLContext(); ~ GLContext(); void Setup(HWND,HDC); void SetupPixelFormat(HDC); private : HWND hWnd; HDC hDC; HGLRC hRC; int format; }; GLContext::GLContext() { this ->hWnd = 0 ; this ->hDC = 0 ; this ->hRC = 0 ; this ->format = 0 ; } GLContext::

OAuth简介(包含简明使用教程)

核能气质少年 提交于 2020-04-28 07:14:16
SSO:用户一次登陆后在多个系统免登录。 博客gem 'doorkeeper' https://i.cnblogs.com/EditPosts.aspx?postid=9255973 OAuth :用户授权第三方应用访问自己的资源无需提供账号密码。 1. 维基百科: OAuth(开放授权)是一个开放标准, 允许用户让第三方应用(网站/app)访问该用户在另一网站(qq, 微博,微信等等)上存储的私密的资源(如照片,视频,联系人列表),而无需将用户名和密码提供给第三方应用。 OAuth允许用户提供一个令牌,而不是用户名和密码来访问他们存放在特定服务提供者的数据。每一个令牌授权一个特定的网站(例如,视频编辑网站)在特定的时段(例如,接下来的2小时内)内访问特定的资源(例如仅仅是某一相册中的视频)。这样,OAuth让用户可以授权第三方网站访问他们存储在另外服务提供者的某些特定信息,而非所有内容。 2 流程图(用git账号登陆第三方网站) 3. devise使用OmniAuth 简单易学的PPT:(作者大🐂) https://ruby-china.org/topics/15825 (笔记和摘录) 目标 OAuth2 协议怎么运行的 看懂基于OAuth2的第三方API 知道怎么用Oauth2 锁你的API(不理解) 课表 Oauth2是什么 通信协定怎么跑 制造Oauth2

Is it possible to use Omniauth with Devise-JWT?

倾然丶 夕夏残阳落幕 提交于 2020-03-23 08:04:11
问题 I have Devise and Devise-JWT configured and working for a React single page application using good old email and password. Now, I'd like my users to be able to log in using Facebook/Google/Twitter, etc. Is Omniauth the way to go? I have Omniauth sort of working with the Developer strategy and I wrote a method that generates the bearer token (I think): class Users::OmniauthCallbacksController < Devise::OmniauthCallbacksController def developer @user = User.from_omniauth(request.env["omniauth

Overriding devise recoverable

旧街凉风 提交于 2020-02-25 23:08:50
问题 As my reputation is lower than 50, so Im not able to comment below the accepted answer in this post In Rails Devise gem how to modify the send_reset_password_instructions method? for more information. I want to customize recoverable.rb in devise. I made a copy of it in my folder with path lib/devise/models/recoverable.rb . The problem is when request to send reset password instruction , I got error undefined method activerecord51? for Devise:Module . How do i solve this? It seems my

Testing that Devise is re-sending confirmation instructions email in a background worker

核能气质少年 提交于 2020-02-25 01:30:02
问题 I want to send Devise confirmation instructions to users a second time if they haven't confirmed within two days of signing up, however I can't seem to get my success case test to pass. Background worker (runs once a day): class ResendConfirmationWorker include Sidekiq::Worker sidekiq_options queue: :resend_confirmation, retry: false def perform d = Time.zone.now - 2.days users = User.where.not(confirmation_sent_at: nil) .where(confirmed_at: nil) .where(created_at: d.beginning_of_day..d.end