Compare commits
7 Commits
v0.8.0
...
d8a35ac3fd
| Author | SHA1 | Date | |
|---|---|---|---|
| d8a35ac3fd | |||
|
|
a91ee2bd0a
|
||
|
|
fcb6923c92
|
||
|
|
0f3b9f176e
|
||
| 822ae2f945 | |||
|
|
96c669ab4e
|
||
|
|
558100c35e
|
@@ -37,4 +37,8 @@ class ApplicationController < ActionController::Base
|
|||||||
format.any { head status }
|
format.any { head status }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def after_sign_in_path_for(user)
|
||||||
|
session[:user_return_to] || root_path
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -108,6 +108,7 @@ class Rs::OauthController < ApplicationController
|
|||||||
def require_signed_in_with_username
|
def require_signed_in_with_username
|
||||||
unless user_signed_in?
|
unless user_signed_in?
|
||||||
username, org = params[:useraddress].split("@")
|
username, org = params[:useraddress].split("@")
|
||||||
|
session[:user_return_to] = request.url
|
||||||
redirect_to new_user_session_path(cn: username, ou: org)
|
redirect_to new_user_session_path(cn: username, ou: org)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,9 +1,12 @@
|
|||||||
class CreateRemoteStorageAuthorizations < ActiveRecord::Migration[7.0]
|
class CreateRemoteStorageAuthorizations < ActiveRecord::Migration[7.0]
|
||||||
def change
|
def change
|
||||||
|
db_type = ActiveRecord::Base.configurations.find_db_config(Rails.env).adapter
|
||||||
|
array_default = db_type == "postgresql" ? [] : [].to_yaml
|
||||||
|
|
||||||
create_table :remote_storage_authorizations do |t|
|
create_table :remote_storage_authorizations do |t|
|
||||||
t.references :user, null: false, foreign_key: true
|
t.references :user, null: false, foreign_key: true
|
||||||
t.string :token
|
t.string :token
|
||||||
t.text :permissions, array: true, default: [].to_yaml
|
t.text :permissions, array: true, default: array_default
|
||||||
t.string :client_id
|
t.string :client_id
|
||||||
t.string :redirect_uri
|
t.string :redirect_uri
|
||||||
t.string :app_name
|
t.string :app_name
|
||||||
|
|||||||
@@ -84,13 +84,12 @@ ActiveRecord::Schema[7.0].define(version: 2023_05_23_120753) do
|
|||||||
t.datetime "confirmed_at", precision: nil
|
t.datetime "confirmed_at", precision: nil
|
||||||
t.datetime "confirmation_sent_at", precision: nil
|
t.datetime "confirmation_sent_at", precision: nil
|
||||||
t.string "unconfirmed_email"
|
t.string "unconfirmed_email"
|
||||||
t.text "ln_login_ciphertext"
|
|
||||||
t.text "ln_password_ciphertext"
|
t.text "ln_password_ciphertext"
|
||||||
t.string "ln_account"
|
t.string "ln_account"
|
||||||
|
t.string "nostr_pubkey"
|
||||||
t.datetime "remember_created_at"
|
t.datetime "remember_created_at"
|
||||||
t.string "remember_token"
|
t.string "remember_token"
|
||||||
t.text "preferences"
|
t.text "preferences"
|
||||||
t.string "nostr_pubkey"
|
|
||||||
t.index ["email"], name: "index_users_on_email", unique: true
|
t.index ["email"], name: "index_users_on_email", unique: true
|
||||||
t.index ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true
|
t.index ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ Sidekiq::Testing.inline! do
|
|||||||
35.times do |n|
|
35.times do |n|
|
||||||
username = Faker::Name.unique.first_name.downcase
|
username = Faker::Name.unique.first_name.downcase
|
||||||
email = Faker::Internet.unique.email
|
email = Faker::Internet.unique.email
|
||||||
|
next if username.length < 3
|
||||||
|
|
||||||
CreateAccount.call(
|
CreateAccount.call(
|
||||||
username: username, domain: "kosmos.org", email: email,
|
username: username, domain: "kosmos.org", email: email,
|
||||||
|
|||||||
@@ -11,7 +11,7 @@
|
|||||||
"postcss-preset-env": "^7.8.3",
|
"postcss-preset-env": "^7.8.3",
|
||||||
"tailwindcss": "^3.2.4"
|
"tailwindcss": "^3.2.4"
|
||||||
},
|
},
|
||||||
"version": "0.8.0",
|
"version": "0.8.1",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build:css:tailwind": "tailwindcss --postcss -i ./app/assets/stylesheets/application.tailwind.css -o ./app/assets/builds/application.css",
|
"build:css:tailwind": "tailwindcss --postcss -i ./app/assets/stylesheets/application.tailwind.css -o ./app/assets/builds/application.css",
|
||||||
"build:css": "yarn run build:css:tailwind"
|
"build:css": "yarn run build:css:tailwind"
|
||||||
|
|||||||
@@ -54,6 +54,11 @@ RSpec.describe 'remoteStorage OAuth Dialog', type: :feature do
|
|||||||
context "when signed out" do
|
context "when signed out" do
|
||||||
let(:user) { create :user }
|
let(:user) { create :user }
|
||||||
|
|
||||||
|
before do
|
||||||
|
allow_any_instance_of(User).to receive(:valid_ldap_authentication?)
|
||||||
|
.with(user.password).and_return(true)
|
||||||
|
end
|
||||||
|
|
||||||
it "prefills the username field in the signin form" do
|
it "prefills the username field in the signin form" do
|
||||||
visit new_rs_oauth_path(useraddress: user.address,
|
visit new_rs_oauth_path(useraddress: user.address,
|
||||||
redirect_uri: "http://example.com",
|
redirect_uri: "http://example.com",
|
||||||
@@ -62,5 +67,19 @@ RSpec.describe 'remoteStorage OAuth Dialog', type: :feature do
|
|||||||
|
|
||||||
expect(find("#user_cn").value).to eq(user.cn)
|
expect(find("#user_cn").value).to eq(user.cn)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "redirects to the OAuth dialog after sign-in" do
|
||||||
|
auth_url = new_rs_oauth_url(useraddress: user.address,
|
||||||
|
redirect_uri: "http://example.com",
|
||||||
|
client_id: "http://example.com",
|
||||||
|
scope: "documents,[photos], contacts:r")
|
||||||
|
visit auth_url
|
||||||
|
|
||||||
|
fill_in "User", with: user.cn
|
||||||
|
fill_in "Password", with: user.password
|
||||||
|
click_button "Log in"
|
||||||
|
|
||||||
|
expect(current_url).to eq(auth_url)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ RSpec.describe CreateLndhubAccountJob, type: :job do
|
|||||||
|
|
||||||
context "with existing credentials stored" do
|
context "with existing credentials stored" do
|
||||||
before do
|
before do
|
||||||
user.ln_login = "foo"
|
user.ln_account = "foo"
|
||||||
user.ln_password = "bar"
|
user.ln_password = "bar"
|
||||||
user.save!
|
user.save!
|
||||||
end
|
end
|
||||||
@@ -36,7 +36,7 @@ RSpec.describe CreateLndhubAccountJob, type: :job do
|
|||||||
expect(WebMock).to_not have_requested(:post, "http://localhost:3023/create")
|
expect(WebMock).to_not have_requested(:post, "http://localhost:3023/create")
|
||||||
|
|
||||||
user.reload
|
user.reload
|
||||||
expect(user.ln_login).to eq("foo")
|
expect(user.ln_account).to eq("foo")
|
||||||
expect(user.ln_password).to eq("bar")
|
expect(user.ln_password).to eq("bar")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user