This repository has been archived by the owner on Sep 11, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Данные для ВК в переменных окружения (#49)
* hide vk redirect url and vk app to env vars
- Loading branch information
Showing
4 changed files
with
61 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,32 @@ | ||
import { Controller } from "@hotwired/stimulus" | ||
|
||
export default class extends Controller { | ||
static values ={ | ||
pkce: Object | ||
} | ||
|
||
connect() { | ||
const VKID = window.VKIDSDK; | ||
const data = this.pkceValue | ||
const challenge = data.challenge | ||
const state = data.state | ||
// Fetch the JSON data from 'auth/challenge' | ||
// Set VKID config with fetched data | ||
VKID.Config.init({ | ||
app: 51989509, // Идентификатор приложения. | ||
redirectUrl: 'http://localhost:3000/auth/vkontakte/callback', // Адрес для перехода после авторизации. | ||
codeChallenge: challenge, | ||
state: state, | ||
//scope: "friends wall" | ||
}); | ||
// Создание экземпляра кнопки. | ||
const oneTap = new VKID.OneTap(); | ||
// Получение контейнера из разметки. | ||
const container = document.getElementById('VkIdSdkOneTap'); | ||
// Проверка наличия кнопки в разметке. | ||
if (container) { | ||
// Отрисовка кнопки в контейнере с именем приложения APP_NAME, светлой темой и на русском языке. | ||
const res = oneTap.render({ container: container, scheme: VKID.Scheme.LIGHT, lang: VKID.Languages.RUS }) | ||
} | ||
}}; | ||
import { Controller } from "@hotwired/stimulus" | ||
|
||
export default class extends Controller { | ||
static values ={ | ||
pkce: Object | ||
} | ||
|
||
connect() { | ||
const VKID = window.VKIDSDK; | ||
const data = this.pkceValue; | ||
const challenge = data.challenge; | ||
const state = data.state; | ||
// Fetch the JSON data from 'auth/challenge' | ||
// Set VKID config with fetched data | ||
VKID.Config.init({ | ||
app: window.VK_APP_ID, // Идентификатор приложения. | ||
redirectUrl: window.VK_AUTH_REDIRECT_URL, // Адрес для перехода после авторизации. | ||
codeChallenge: challenge, | ||
state: state, | ||
//scope: "friends wall" | ||
}); | ||
// Создание экземпляра кнопки. | ||
const oneTap = new VKID.OneTap(); | ||
// Получение контейнера из разметки. | ||
const container = document.getElementById('VkIdSdkOneTap'); | ||
// Проверка наличия кнопки в разметке. | ||
if (container) { | ||
// Отрисовка кнопки в контейнере с именем приложения APP_NAME, светлой темой и на русском языке. | ||
const res = oneTap.render({ container: container, scheme: VKID.Scheme.LIGHT, lang: VKID.Languages.RUS }) | ||
} | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,26 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="utf-8"> | ||
<title>Where my likes</title> | ||
<meta name="viewport" content="width=device-width,initial-scale=1"> | ||
<%= csrf_meta_tags %> | ||
<%= csp_meta_tag %> | ||
<script src="https://unpkg.com/@vkid/sdk@<3.0.0/dist-sdk/umd/index.js"></script> | ||
<%= stylesheet_link_tag "application", "data-turbo-track": "reload" %> | ||
<link rel="preconnect" href="https://fonts.googleapis.com"> | ||
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin> | ||
<link href="https://fonts.googleapis.com/css2?family=Raleway:ital,wght@0,100..900;1,100..900&display=swap" rel="stylesheet"> | ||
<%= javascript_include_tag "application", "data-turbo-track": "reload", type: "module" %> | ||
</head> | ||
<body> | ||
<%= render partial: "partial_content/navbar"%> | ||
<main class="raleway"> | ||
<%= yield %> | ||
</main> | ||
<%= render partial: "partial_content/footer"%> | ||
</body> | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="utf-8"> | ||
<title>Where my likes</title> | ||
<meta name="viewport" content="width=device-width,initial-scale=1"> | ||
<%= csrf_meta_tags %> | ||
<%= csp_meta_tag %> | ||
<script src="https://unpkg.com/@vkid/sdk@<3.0.0/dist-sdk/umd/index.js"></script> | ||
<script> | ||
window.VK_AUTH_REDIRECT_URL = "<%= Rails.VK_AUTH_REDIRECT_URL %>" | ||
window.VK_APP_ID = "<%= Rails.VK_APP_ID %>" | ||
</script> | ||
<%= stylesheet_link_tag "application", "data-turbo-track": "reload" %> | ||
<link rel="preconnect" href="https://fonts.googleapis.com"> | ||
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin> | ||
<link href="https://fonts.googleapis.com/css2?family=Raleway:ital,wght@0,100..900;1,100..900&display=swap" rel="stylesheet"> | ||
<%= javascript_include_tag "application", "data-turbo-track": "reload", type: "module" %> | ||
</head> | ||
<body> | ||
<%= render partial: "partial_content/navbar"%> | ||
<main class="raleway"> | ||
<%= yield %> | ||
</main> | ||
<%= render partial: "partial_content/footer"%> | ||
</body> |