chore(i18n,learn): processed translations (#48391)

This commit is contained in:
camperbot
2022-11-04 15:53:44 +00:00
committed by GitHub
parent d7abe32210
commit 084bf7600f
22 changed files with 65 additions and 83 deletions

View File

@@ -26,11 +26,11 @@ console.log(arr);
# --instructions--
Use a destructuring assignment with the rest parameter to emulate the behavior of `Array.prototype.slice()`. `removeFirstTwo()` should return a sub-array of the original array `list` with the first two elements omitted.
استخدام تشكيل مخرج للمعلومات (destructuring assignment) مع الحجة (parameter) الباقية لمحاكاة سلوك `Array.prototype.slice()`. يجب أن ينتج `removeFirstTwo()` قائمة فرعية (sub-array) من قائمة `list` الأصلية دون العنصرين الأولين.
# --hints--
`removeFirstTwo([1, 2, 3, 4, 5])` should be `[3, 4, 5]`
يجب أن ينتج `removeFirstTwo([1, 2, 3, 4, 5])` قائمة `[3, 4, 5]`
```js
const testArr_ = [1, 2, 3, 4, 5];
@@ -38,7 +38,7 @@ const testArrWORemoved_ = removeFirstTwo(testArr_);
assert(testArrWORemoved_.every((e, i) => e === i + 3) && testArrWORemoved_.length === 3);
```
`removeFirstTwo()` should not modify `list`
يجب ألا يعدل `removeFirstTwo()` قائمة `list`
```js
const testArr_ = [1, 2, 3, 4, 5];

View File

@@ -58,27 +58,27 @@ myRegex.lastIndex = 0;
assert(!myRegex.test('Frank Roosevelt'));
```
Your regex `myRegex` should return `false` for the string `FranklinRoosevelt`
يجب أن ينتج regex الآتي `myRegex` قيمة `false` للمقطع `FranklinRoosevelt`
```js
myRegex.lastIndex = 0;
assert(!myRegex.test('FranklinRoosevelt'));
```
Your regex `myRegex` should return `false` for the string `EleanorRoosevelt`
يجب أن ينتج regex الآتي `myRegex` قيمة `false` للمقطع `EleanorRoosevelt`
```js
myRegex.lastIndex = 0;
assert(!myRegex.test('EleanorRoosevelt'));
```
You should use `.test()` to test the regex.
يجب عليك استخدام `.test()` لاختبار regex.
```js
assert(code.match(/myRegex.test\(\s*myString\s*\)/));
```
Your result should return `true`.
يجب أن تنتج `true`.
```js
assert(result === true);

View File

@@ -18,9 +18,7 @@ The basic path this kind of authentication will follow in your app is:
Strategies with OAuth require you to have at least a *Client ID* and a *Client Secret* which is a way for the service to verify who the authentication request is coming from and if it is valid. These are obtained from the site you are trying to implement authentication with, such as GitHub, and are unique to your app--**THEY ARE NOT TO BE SHARED** and should never be uploaded to a public repository or written directly in your code. A common practice is to put them in your `.env` file and reference them like so: `process.env.GITHUB_CLIENT_ID`. For this challenge you are going to use the GitHub strategy.
Follow these instructions to obtain your *Client ID and Secret* from GitHub. Go to your GitHub profile settings and click 'developer settings', then <a href="https://github.com/settings/developers" target="_blank" rel="noopener noreferrer nofollow">'OAuth Apps'</a>. Click 'New OAuth App', then give your app a name, paste in the URL to your Replit homepage (**Not the project code's url**) and, for the callback URL, paste in the same URL as the homepage but add `/auth/github/callback` to the end of it. This is where users will be redirected after authenticating on GitHub. After you do all that, click 'Register application'.
On the next page, click 'Generate a new client secret' to create a new client secret. Save the client ID and your client secret in your project's `.env` file as `GITHUB_CLIENT_ID` and `GITHUB_CLIENT_SECRET`.
Follow <a href="https://www.freecodecamp.org/news/how-to-set-up-a-github-oauth-application/" target="_blank" rel="noopener noreferrer nofollow">these instructions</a> to obtain your *Client ID and Secret* from GitHub. Set the homepage URL to your Replit homepage (**not the project code's URL**), and set the callback URL to the same homepage URL with `/auth/github/callback` appended to the end. Save the client ID and your client secret in your project's `.env` file as `GITHUB_CLIENT_ID` and `GITHUB_CLIENT_SECRET`.
In your `routes.js` file, add `showSocialAuth: true` to the homepage route, after `showRegistration: true`. Now, create 2 routes accepting GET requests: `/auth/github` and `/auth/github/callback`. The first should only call passport to authenticate `'github'`. The second should call passport to authenticate `'github'` with a failure redirect to `/`, and then if that is successful redirect to `/profile` (similar to your last project).

View File

@@ -18,9 +18,7 @@ dashedName: implementation-of-social-authentication
在 OAuth 驗證策略中,我們至少需要提供 *Client ID**Client Secret*,這樣第三方平臺就會獲悉驗證請求的來源,以及這個來源是否有效。 爲此,需要去我們使用的第三方驗證平臺(比如 GitHub獲取這兩個字段的值。 注意,我們獲取到的這個值是唯一的,僅對我們的當前 app 有效——**因此,千萬不要分享給別人**,更不要上傳到公共倉庫或者直接寫在代碼裏。 通常,我們會把它們放在 `.env` 文件裏,並通過 `process.env.GITHUB_CLIENT_ID` 獲取。 For this challenge you are going to use the GitHub strategy.
Follow these instructions to obtain your *Client ID and Secret* from GitHub. Go to your GitHub profile settings and click 'developer settings', then <a href="https://github.com/settings/developers" target="_blank" rel="noopener noreferrer nofollow">'OAuth Apps'</a>. Click 'New OAuth App', then give your app a name, paste in the URL to your Replit homepage (**Not the project code's url**) and, for the callback URL, paste in the same URL as the homepage but add `/auth/github/callback` to the end of it. This is where users will be redirected after authenticating on GitHub. After you do all that, click 'Register application'.
On the next page, click 'Generate a new client secret' to create a new client secret. Save the client ID and your client secret in your project's `.env` file as `GITHUB_CLIENT_ID` and `GITHUB_CLIENT_SECRET`.
Follow <a href="https://www.freecodecamp.org/news/how-to-set-up-a-github-oauth-application/" target="_blank" rel="noopener noreferrer nofollow">these instructions</a> to obtain your *Client ID and Secret* from GitHub. Set the homepage URL to your Replit homepage (**not the project code's URL**), and set the callback URL to the same homepage URL with `/auth/github/callback` appended to the end. Save the client ID and your client secret in your project's `.env` file as `GITHUB_CLIENT_ID` and `GITHUB_CLIENT_SECRET`.
In your `routes.js` file, add `showSocialAuth: true` to the homepage route, after `showRegistration: true`. Now, create 2 routes accepting GET requests: `/auth/github` and `/auth/github/callback`. The first should only call passport to authenticate `'github'`. The second should call passport to authenticate `'github'` with a failure redirect to `/`, and then if that is successful redirect to `/profile` (similar to your last project).

View File

@@ -18,9 +18,7 @@ dashedName: implementation-of-social-authentication
在 OAuth 验证策略中,我们至少需要提供 *Client ID**Client Secret*,这样第三方平台就会获悉验证请求的来源,以及这个来源是否有效。 为此,需要去我们使用的第三方验证平台(比如 GitHub获取这两个字段的值。 注意,我们获取到的这个值是唯一的,仅对我们的当前 app 有效——**因此,千万不要分享给别人**,更不要上传到公共仓库或者直接写在代码里。 通常,我们会把它们放在 `.env` 文件里,并通过 `process.env.GITHUB_CLIENT_ID` 获取。 For this challenge you are going to use the GitHub strategy.
Follow these instructions to obtain your *Client ID and Secret* from GitHub. Go to your GitHub profile settings and click 'developer settings', then <a href="https://github.com/settings/developers" target="_blank" rel="noopener noreferrer nofollow">'OAuth Apps'</a>. Click 'New OAuth App', then give your app a name, paste in the URL to your Replit homepage (**Not the project code's url**) and, for the callback URL, paste in the same URL as the homepage but add `/auth/github/callback` to the end of it. This is where users will be redirected after authenticating on GitHub. After you do all that, click 'Register application'.
On the next page, click 'Generate a new client secret' to create a new client secret. Save the client ID and your client secret in your project's `.env` file as `GITHUB_CLIENT_ID` and `GITHUB_CLIENT_SECRET`.
Follow <a href="https://www.freecodecamp.org/news/how-to-set-up-a-github-oauth-application/" target="_blank" rel="noopener noreferrer nofollow">these instructions</a> to obtain your *Client ID and Secret* from GitHub. Set the homepage URL to your Replit homepage (**not the project code's URL**), and set the callback URL to the same homepage URL with `/auth/github/callback` appended to the end. Save the client ID and your client secret in your project's `.env` file as `GITHUB_CLIENT_ID` and `GITHUB_CLIENT_SECRET`.
In your `routes.js` file, add `showSocialAuth: true` to the homepage route, after `showRegistration: true`. Now, create 2 routes accepting GET requests: `/auth/github` and `/auth/github/callback`. The first should only call passport to authenticate `'github'`. The second should call passport to authenticate `'github'` with a failure redirect to `/`, and then if that is successful redirect to `/profile` (similar to your last project).

View File

@@ -18,9 +18,7 @@ La ruta básica que seguirá este tipo de autenticación en tu aplicación es:
Las estrategias con OAuth requieren que tengas al menos un *Client ID* y un *Client Secret* que es una forma de que el servicio verifique de quién viene la solicitud de autentificación y si es válida. Estos se obtienen del sitio con el que intentas implementar la autentificación, como GitHub, y son únicos para tu aplicación: **NO SE DEBEN COMPARTIR** y nunca deben subirse a un repositorio público ni escribirse directamente en tu código. Una práctica común es ponerlos en tu archivo `.env` y referenciarlos así: `process.env.GITHUB_CLIENT_ID`. For this challenge you are going to use the GitHub strategy.
Follow these instructions to obtain your *Client ID and Secret* from GitHub. Go to your GitHub profile settings and click 'developer settings', then <a href="https://github.com/settings/developers" target="_blank" rel="noopener noreferrer nofollow">'OAuth Apps'</a>. Click 'New OAuth App', then give your app a name, paste in the URL to your Replit homepage (**Not the project code's url**) and, for the callback URL, paste in the same URL as the homepage but add `/auth/github/callback` to the end of it. This is where users will be redirected after authenticating on GitHub. After you do all that, click 'Register application'.
On the next page, click 'Generate a new client secret' to create a new client secret. Save the client ID and your client secret in your project's `.env` file as `GITHUB_CLIENT_ID` and `GITHUB_CLIENT_SECRET`.
Follow <a href="https://www.freecodecamp.org/news/how-to-set-up-a-github-oauth-application/" target="_blank" rel="noopener noreferrer nofollow">these instructions</a> to obtain your *Client ID and Secret* from GitHub. Set the homepage URL to your Replit homepage (**not the project code's URL**), and set the callback URL to the same homepage URL with `/auth/github/callback` appended to the end. Save the client ID and your client secret in your project's `.env` file as `GITHUB_CLIENT_ID` and `GITHUB_CLIENT_SECRET`.
In your `routes.js` file, add `showSocialAuth: true` to the homepage route, after `showRegistration: true`. Now, create 2 routes accepting GET requests: `/auth/github` and `/auth/github/callback`. The first should only call passport to authenticate `'github'`. The second should call passport to authenticate `'github'` with a failure redirect to `/`, and then if that is successful redirect to `/profile` (similar to your last project).

View File

@@ -18,9 +18,7 @@ The basic path this kind of authentication will follow in your app is:
Strategies with OAuth require you to have at least a *Client ID* and a *Client Secret* which is a way for the service to verify who the authentication request is coming from and if it is valid. These are obtained from the site you are trying to implement authentication with, such as GitHub, and are unique to your app--**THEY ARE NOT TO BE SHARED** and should never be uploaded to a public repository or written directly in your code. A common practice is to put them in your `.env` file and reference them like so: `process.env.GITHUB_CLIENT_ID`. For this challenge you are going to use the GitHub strategy.
Follow these instructions to obtain your *Client ID and Secret* from GitHub. Go to your GitHub profile settings and click 'developer settings', then <a href="https://github.com/settings/developers" target="_blank" rel="noopener noreferrer nofollow">'OAuth Apps'</a>. Click 'New OAuth App', then give your app a name, paste in the URL to your Replit homepage (**Not the project code's url**) and, for the callback URL, paste in the same URL as the homepage but add `/auth/github/callback` to the end of it. This is where users will be redirected after authenticating on GitHub. After you do all that, click 'Register application'.
On the next page, click 'Generate a new client secret' to create a new client secret. Save the client ID and your client secret in your project's `.env` file as `GITHUB_CLIENT_ID` and `GITHUB_CLIENT_SECRET`.
Follow <a href="https://www.freecodecamp.org/news/how-to-set-up-a-github-oauth-application/" target="_blank" rel="noopener noreferrer nofollow">these instructions</a> to obtain your *Client ID and Secret* from GitHub. Set the homepage URL to your Replit homepage (**not the project code's URL**), and set the callback URL to the same homepage URL with `/auth/github/callback` appended to the end. Save the client ID and your client secret in your project's `.env` file as `GITHUB_CLIENT_ID` and `GITHUB_CLIENT_SECRET`.
In your `routes.js` file, add `showSocialAuth: true` to the homepage route, after `showRegistration: true`. Now, create 2 routes accepting GET requests: `/auth/github` and `/auth/github/callback`. The first should only call passport to authenticate `'github'`. The second should call passport to authenticate `'github'` with a failure redirect to `/`, and then if that is successful redirect to `/profile` (similar to your last project).

View File

@@ -26,11 +26,11 @@ Le variabili `a` e `b` prendono il primo e il secondo valore dall'array. Dopodic
# --instructions--
Use a destructuring assignment with the rest parameter to emulate the behavior of `Array.prototype.slice()`. `removeFirstTwo()` should return a sub-array of the original array `list` with the first two elements omitted.
Usa un'assegnazione destrutturante con il parametro rest per emulare il comportamento di `Array.prototype.slice()`. `removeFirstTwo()` dovrebbe restituire un sotto-array dell'array originario `list` con i primi due elementi omessi.
# --hints--
`removeFirstTwo([1, 2, 3, 4, 5])` should be `[3, 4, 5]`
`removeFirstTwo([1, 2, 3, 4, 5])` dovrebbe essere `[3, 4, 5]`
```js
const testArr_ = [1, 2, 3, 4, 5];
@@ -38,7 +38,7 @@ const testArrWORemoved_ = removeFirstTwo(testArr_);
assert(testArrWORemoved_.every((e, i) => e === i + 3) && testArrWORemoved_.length === 3);
```
`removeFirstTwo()` should not modify `list`
`removeFirstTwo()` non dovrebbe modificare `list`
```js
const testArr_ = [1, 2, 3, 4, 5];

View File

@@ -8,9 +8,9 @@ dashedName: announce-new-users
# --description--
Molte chat room sono in grado di annunciare quando un utente si connette o si disconnette e mostrarlo a tutti gli utenti connessi nella chat. Considerando che stai già emettendo un evento alla connessione e alla disconnessione, dovrai solo modificare questo evento per supportare questa caratteristica. The most logical way of doing so is sending 3 pieces of data with the event: the username of the user who connected/disconnected, the current user count, and if that username connected or disconnected.
Molte chat room sono in grado di annunciare quando un utente si connette o si disconnette e mostrarlo a tutti gli utenti connessi nella chat. Considerando che stai già emettendo un evento alla connessione e alla disconnessione, dovrai solo modificare questo evento per supportare questa caratteristica. Il modo più logico di farlo è inviare di 3 pezzi di dati con l'evento: il nome dell'utente che si è connesso/disconnesso, il conteggio corrente degli utenti, e se questo username si è connesso o disconnesso.
Change the event name to `'user'`, and pass an object along containing the fields `username`, `currentUsers`, and `connected` (to be `true` in case of connection, or `false` for disconnection of the user sent). Be sure to change both `'user count'` events and set the disconnect one to send `false` for the field `connected` instead of `true` like the event emitted on connect.
Cambia il nome dell'evento in `'user'` e passa insieme a esso un oggetto contenente i campi `username`, `currentUsers` e `connected` (`true` in caso di connessione, o `false` per la disconnessione dell'utente inviato). Assicurati di modificare entrambi gli eventi `'user count'` e impostare quello per la disconnessione in modo che invii `false` per il campo `connected` invece di `true` come fa l'evento emesso alla connessione.
```js
io.emit('user', {
@@ -34,11 +34,11 @@ socket.on('user', data => {
});
```
Invia la tua pagina quando pensi di averlo fatto bene. If you're running into errors, you can check out <a href="https://forum.freecodecamp.org/t/advanced-node-and-express/567135/3#announce-new-users-10" target="_blank" rel="noopener noreferrer nofollow">the project completed up to this point </a>.
Invia la tua pagina quando pensi di averlo fatto bene. Se stai avendo errori, puoi vedere <a href="https://forum.freecodecamp.org/t/advanced-node-and-express/567135/3#announce-new-users-10" target="_blank" rel="noopener noreferrer nofollow">il progetto completato fino a questo punto</a>.
# --hints--
Event `'user'` should be emitted with `name`, `currentUsers`, and `connected`.
L'evento `'user'` dovrebbe essere emesso con `name`, `currentUsers` e `connected`.
```js
async (getUserInput) => {

View File

@@ -65,7 +65,7 @@ console.log('user ' + socket.request.user.username + ' connected');
Scriverà sulla console del server chi si è connesso!
Invia la tua pagina quando pensi di averlo fatto correttamente. If you're running into errors, you can <a href="https://forum.freecodecamp.org/t/advanced-node-and-express/567135#authentication-with-socketio-9" target="_blank" rel="noopener noreferrer nofollow">check out the project up to this point</a>.
Invia la tua pagina quando pensi di averlo fatto correttamente. Se incontri degli errori, puoi vedere <a href="https://forum.freecodecamp.org/t/advanced-node-and-express/567135#authentication-with-socketio-9" target="_blank" rel="noopener noreferrer nofollow">il progetto fino a questo punto</a>.
# --hints--

View File

@@ -38,11 +38,11 @@ socket.on('user count', function(data) {
Ora, prova a caricare la tua app e a fare l'autenticazione: dovresti vedere nella tua console del client un '1' che rappresenta il numero attuale di utenti! Prova a caricare altri client, e autenticati in ognuno di essi per vedere il numero che aumenta.
Invia la tua pagina quando pensi di averlo fatto correttamente. If you're running into errors, you can <a href="https://forum.freecodecamp.org/t/advanced-node-and-express/567135#communicate-by-emitting-7" target="_blank" rel="noopener noreferrer nofollow">check out the project completed up to this point</a>.
Invia la tua pagina quando pensi di averlo fatto correttamente. Se incontri degli errori, puoi vedere <a href="https://forum.freecodecamp.org/t/advanced-node-and-express/567135#communicate-by-emitting-7" target="_blank" rel="noopener noreferrer nofollow">il progetto completato fino a questo punto</a>.
# --hints--
`currentUsers` should be defined.
`currentUsers` dovrebbe essere definito.
```js
async (getUserInput) => {

View File

@@ -12,9 +12,9 @@ Tornando alla sezione sulla sicurezza delle informazioni, potresti ricordare che
`bcrypt@~5.0.0` è già stato aggiunto come dipendenza, quindi richiedilo nel tuo server. Dovrai gestire l'hashing in 2 aree chiave: dove gestisci la registrazione/salvataggio di un nuovo account, e quando controlli per vedere se una password è corretta al momento dell'accesso.
Currently on your registration route, you insert a user's plaintext password into the database like so: `password: req.body.password`. Hash the passwords instead by adding the following before your database logic: `const hash = bcrypt.hashSync(req.body.password, 12);`, and replacing the `req.body.password` in the database saving with just `password: hash`.
Attualmente sul tuo percorso di registrazione, inserisci la password di un utente come testo non crittografato nel database in questo modo: `password: req.body.password`. Esegui l'hashing della password aggiungendo quanto segue prima della logica del database `const hash = bcrypt.hashSync(req.body.password, 12);`, e sostituisci `req.body.password` nel database salvando solo `password: hash`.
On your authentication strategy, you check for the following in your code before completing the process: `if (password !== user.password) return done(null, false);`. Dopo aver apportato le modifiche precedenti, `user.password` è diventato un hash. Prima di apportare una modifica al codice esistente, nota come la dichiarazione verifica se la password è **non** uguale, quindi restituisce not-authenticated. With this in mind, change that code to look as follows to properly check the password entered against the hash:
Nella tua strategia di autenticazione, controlla quanto segue nel codice prima di completare il processo: `if (password !== user.password) return done(null, false);`. Dopo aver apportato le modifiche precedenti, `user.password` è diventato un hash. Prima di apportare una modifica al codice esistente, nota come la dichiarazione verifica se la password è **non** uguale, quindi restituisce not-authenticated. Con questo in mente, cambia il codice in modo che appaia come segue per confrontare correttamente la password inserita con l'hash:
```js
if (!bcrypt.compareSync(password, user.password)) {
@@ -22,9 +22,9 @@ if (!bcrypt.compareSync(password, user.password)) {
}
```
That is all it takes to implement one of the most important security features when you have to store passwords.
Questo è tutto quello che serve per implementare una delle caratteristiche di sicurezza più importanti quando si devono memorizzare le password.
Invia la tua pagina quando pensi di averlo fatto correttamente. If you're running into errors, you can <a href="https://forum.freecodecamp.org/t/advanced-node-and-express/567135#hashing-your-passwords-1" target="_blank" rel="noopener noreferrer nofollow">check out the project completed up to this point</a>.
Invia la tua pagina quando pensi di averlo fatto correttamente. Se incontri degli errori, puoi vedere <a href="https://forum.freecodecamp.org/t/advanced-node-and-express/567135#hashing-your-passwords-1" target="_blank" rel="noopener noreferrer nofollow">il progetto completato fino a questo punto</a>.
# --hints--

View File

@@ -8,29 +8,29 @@ dashedName: how-to-put-a-profile-together
# --description--
Now that you can ensure the user accessing the `/profile` is authenticated, you can use the information contained in `req.user` on your page.
Ora che puoi garantire che l'utente che accede al `/profile` sia autenticato, puoi utilizzare le informazioni contenute in `req.user` sulla tua pagina.
Pass an object containing the property `username` and value of `req.user.username` as the second argument for the `render` method of the profile view.
Passa un oggetto contenente la proprietà `username` e il valore di `req.user.username` come secondo argomento per il metodo `render` della vista del profilo.
Then, go to your `profile.pug` view, and add the following line below the existing `h1` element, and at the same level of indentation:
Quindi, vai alla tua vista `profile.pug` e aggiungi la seguente riga sotto l'elemento `h1` esistente, e allo stesso livello di indentazione:
```pug
h2.center#welcome Welcome, #{username}!
```
This creates an `h2` element with the class `center` and id `welcome` containing the text `Welcome,` followed by the username.
Questo crea un elemento `h2` di classe `center` e con id `welcome` contenente il testo `Welcome,` seguito dal nome utente.
Also, in `profile.pug`, add a link referring to the `/logout` route, which will host the logic to unauthenticate a user:
Inoltre, in `profile.pug`, aggiungi un link relativo alla rotta `/logout`, che ospiterà la logica per disconnettere un utente:
```pug
a(href='/logout') Logout
```
Submit your page when you think you've got it right. If you're running into errors, you can <a href="https://forum.freecodecamp.org/t/advanced-node-and-express/567135#how-to-put-a-profile-together-9" target="_blank" rel="noopener noreferrer nofollow">check out the project completed up to this point</a>.
Invia la tua pagina quando pensi che sia tutto corretto. Se incontri degli errori, puoi vedere <a href="https://forum.freecodecamp.org/t/advanced-node-and-express/567135#how-to-put-a-profile-together-9" target="_blank" rel="noopener noreferrer nofollow">il progetto completato fino a questo punto</a>.
# --hints--
You should correctly add a Pug render variable to `/profile`.
Dovresti aggiungere correttamente una variabile di rendering Pug a `/profile`.
```js
async (getUserInput) => {

View File

@@ -12,7 +12,7 @@ L'ultima parte della configurazione dell'autenticazione con GitHub è creare la
Per impostare la strategia GitHub, devi dire al Passport di utilizzare un `GitHubStrategy` istantanziato, che accetta 2 argomenti: un oggetto (contenente `clientID`, `clientSecret`, e `callbackURL`) e una funzione da chiamare quando un utente viene autenticato con successo, che determinerà se l'utente è nuovo e quali campi salvare inizialmente nell'oggetto database dell'utente. Questo è comune in molte strategie, ma alcune possono richiedere ulteriori informazioni, come indicato nel README di quella specifica strategia GitHub. Ad esempio, Google richiede anche un *ambito* che determina il tipo di informazioni che la tua richiesta sta chiedendo di ricevere e chiede all'utente di approvare tale accesso.
The current strategy you are implementing authenticates users using a GitHub account and OAuth 2.0 tokens. L'ID del client e il segreto ottenuto durante la creazione di un'applicazione vengono forniti come opzioni quando crei la strategia. La strategia inoltre richiede un callback `verify`, che riceve un token di accesso e un token opzionale di refresh, come anche un `profile` che contiene il profilo dell'utente di GitHub autenticato. Il callback `verify` deve chiamare `cb` fornendo un utente per completare l'autenticazione.
La strategia che stai usando autentica gli utenti usando un account GitHub e dei token OAuth 2.0. L'ID del client e il segreto ottenuto durante la creazione di un'applicazione vengono forniti come opzioni quando crei la strategia. La strategia inoltre richiede un callback `verify`, che riceve un token di accesso e un token opzionale di refresh, come anche un `profile` che contiene il profilo dell'utente di GitHub autenticato. Il callback `verify` deve chiamare `cb` fornendo un utente per completare l'autenticazione.
Ecco come la tua nuova strategia dovrebbe essere a questo punto:
@@ -31,7 +31,7 @@ passport.use(new GitHubStrategy({
La tua autenticazione non avrà ancora successo, anzi lancerà un errore senza la logica del database e la chiamata, ma se provi dovrebbe registrare il tuo profilo GitHub sulla tua console!
Invia la tua pagina quando pensi di averlo fatto correttamente. If you're running into errors, you can <a href="https://forum.freecodecamp.org/t/advanced-node-and-express/567135#implementation-of-social-authentication-ii-4" target="_blank" rel="noopener noreferrer nofollow">check out the project completed up to this point</a>.
Invia la tua pagina quando pensi di averlo fatto correttamente. Se incontri degli errori, puoi vedere <a href="https://forum.freecodecamp.org/t/advanced-node-and-express/567135#implementation-of-social-authentication-ii-4" target="_blank" rel="noopener noreferrer nofollow">il progetto completato fino a questo punto</a>.
# --hints--

View File

@@ -18,13 +18,11 @@ Il percorso di base che seguirà questo tipo di autenticazione nella tua app è:
Le strategie con OAuth richiedono di avere almeno un *ID client* e un *Client Secret* che è un modo per il servizio di verificare da chi proviene la richiesta di autenticazione e se è valida. Questi sono ottenuti dal sito con cui si sta tentando di implementare l'autenticazione, ad esempio GitHub, e sono unici per la tua app--**NON DEVONO ESSERE CONDIVISI** e non dovrebbero mai essere caricati in un archivio pubblico o scritti direttamente nel tuo codice. Una pratica comune è metterli nel tuo file `.env` e fare riferimento a loro in questo modo: `process.env.GITHUB_CLIENT_ID`. Per questa sfida userai la strategia GitHub.
Segui questa strategia per ottenere *Client ID e Segreto* da GitHub. Vai sulle impostazioni del tuo profilo GitHub e clicca su 'developer settings', poi su <a href="https://github.com/settings/developers" target="_blank" rel="noopener noreferrer nofollow">'OAuth Apps'</a>. Clicca su 'New OAuth App', poi dai un nome alla tua app, incolla l'URL alla tua home page Replit (**Non l'url al codice del progetto**) e, per l'URL di callback, incolla lo stesso URL dell'home page ma aggiungi `/auth/github/callback` alla sua fine. È qui che gli utenti verranno reindirizzati dopo l'autenticazione su GitHub. Dopo aver fatto tutto questo, clicca su 'Register application'.
Follow <a href="https://www.freecodecamp.org/news/how-to-set-up-a-github-oauth-application/" target="_blank" rel="noopener noreferrer nofollow">these instructions</a> to obtain your *Client ID and Secret* from GitHub. Set the homepage URL to your Replit homepage (**not the project code's URL**), and set the callback URL to the same homepage URL with `/auth/github/callback` appended to the end. Save the client ID and your client secret in your project's `.env` file as `GITHUB_CLIENT_ID` and `GITHUB_CLIENT_SECRET`.
Nella pagina successiva, clicca su 'Generate a new client secret' per creare un nuovo segreto client. Salva l'ID client e il tuo segreto client nel file `.env` del tuo progetto come `GITHUB_CLIENT_ID` e `GITHUB_CLIENT_SECRET`.
In your `routes.js` file, add `showSocialAuth: true` to the homepage route, after `showRegistration: true`. Now, create 2 routes accepting GET requests: `/auth/github` and `/auth/github/callback`. The first should only call passport to authenticate `'github'`. The second should call passport to authenticate `'github'` with a failure redirect to `/`, and then if that is successful redirect to `/profile` (similar to your last project).
Nel tuo file `routes.js`, aggiungi `showSocialAuth: true` alla rotta homepage, dopo `showRegistration: true`. Ora, crea 2 rotte che accettano le richieste GET: `/auth/github` e `/auth/github/callback`. La prima dovrebbe chiamare solo passport per autenticare `'github'`. La seconda dovrebbe chiamare passport per autenticare `'github'` con un reindirizzamento fallito a `/`, e poi, se questo è riuscito, reindirizzare a `/profile` (simile al tuo ultimo progetto).
Un esempio di come `/auth/github/callback` deve essere è simile al modo in cui hai gestito un normale login:
An example of how `/auth/github/callback` should look is similar to how you handled a normal login:
```js
app.route('/login')
@@ -33,11 +31,11 @@ app.route('/login')
});
```
Invia la tua pagina quando pensi che sia tutto corretto. Se incontri degli errori, puoi vedere <a href="https://forum.freecodecamp.org/t/advanced-node-and-express/567135#implementation-of-social-authentication-3" target="_blank" rel="noopener noreferrer nofollow">il progetto fino a questo punto</a>.
Submit your page when you think you've got it right. If you're running into errors, you can <a href="https://forum.freecodecamp.org/t/advanced-node-and-express/567135#implementation-of-social-authentication-3" target="_blank" rel="noopener noreferrer nofollow">check out the project up to this point</a>.
# --hints--
La rotta `/auth/github` dovrebbe essere corretta.
Route `/auth/github` should be correct.
```js
async (getUserInput) => {
@@ -68,7 +66,7 @@ async (getUserInput) => {
}
```
La rotta `/auth/github/callback` dovrebbe essere corretta.
Route `/auth/github/callback` should be correct.
```js
async (getUserInput) => {

View File

@@ -8,9 +8,9 @@ dashedName: logging-a-user-out
# --description--
Creare la logica per il logout è semplice. The route should just unauthenticate the user, and redirect to the home page instead of rendering any view.
Creare la logica per il logout è semplice. La rotta dovrebbe semplicemente de-autenticare l'utente e reindirizzarlo alla home page, senza renderizzare alcuna vista.
In passport, unauthenticating a user is as easy as just calling `req.logout()` before redirecting. Add this `/logout` route to do that:
In passport, per de-autenticare un utente è sufficiente invocare `req.logout()` prima del reindirizzamento. Aggiungi questa rotta `/logout` per farlo:
```js
app.route('/logout')
@@ -20,7 +20,7 @@ app.route('/logout')
});
```
You may have noticed that you are not handling missing pages (404). Il modo comune per gestirle in Node è con il seguente middleware. Prosegui e aggiungilo dopo tutte le tue rotte:
Potresti aver notato che non stai gestendo pagine mancanti (404). Il modo comune per gestirle in Node è con il seguente middleware. Prosegui e aggiungilo dopo tutte le tue rotte:
```js
app.use((req, res, next) => {
@@ -30,7 +30,7 @@ app.use((req, res, next) => {
});
```
Invia la tua pagina quando pensi di averlo fatto correttamente. If you're running into errors, you can <a href="https://forum.freecodecamp.org/t/advanced-node-and-express/567135#logging-a-user-out-10" target="_blank" rel="noopener noreferrer nofollow">check out the project completed up to this point</a>.
Invia la tua pagina quando pensi di averlo fatto correttamente. Se incontri degli errori, puoi vedere <a href="https://forum.freecodecamp.org/t/advanced-node-and-express/567135#logging-a-user-out-10" target="_blank" rel="noopener noreferrer nofollow">il progetto completato fino a questo punto</a>.
# --hints--
@@ -49,7 +49,7 @@ async (getUserInput) => {
}
```
`/logout` should redirect to the home page.
`/logout` dovrebbe reindirizzare alla home page.
```js
async (getUserInput) => {

View File

@@ -22,13 +22,13 @@ All'interno del codice di invio del modulo, dovresti emettere un evento dopo ave
socket.emit('chat message', messageToSend);
```
Ora, sul tuo server, si dovrebbe ascoltare il socket in attesa dell'evento `'chat message'` con i dati chiamati `message`. Once the event is received, it should emit the event `'chat message'` to all sockets using `io.emit`, sending a data object containing the `username` and `message`.
Ora, sul tuo server, si dovrebbe ascoltare il socket in attesa dell'evento `'chat message'` con i dati chiamati `message`. Una volta ricevuto l'evento, dovrebbe emettere l'evento `'chat message'` a tutti i socket usando `io.emit`, inviando un oggetto dati contenente `username` e `message`.
In `client.js`, you should now listen for event `'chat message'` and, when received, append a list item to `#messages` with the username, a colon, and the message!
In `client.js`, dovresti ora rimanere in ascolto per l'evento `'chat message'` e, quando ricevuto, aggiungi un elemento di lista a `#messages` con lo username, due punti e il messaggio!
A questo punto, la chat dovrebbe essere completamente funzionante e in grado di inviare messaggi attraverso tutti i client!
Invia la tua pagina quando pensi di averlo fatto correttamente. If you're running into errors, you can <a href="https://forum.freecodecamp.org/t/advanced-node-and-express/567135#send-and-display-chat-messages-11" target="_blank" rel="noopener noreferrer nofollow">check out the project completed up to this point</a>.
Invia la tua pagina quando pensi di averlo fatto correttamente. Se incontri degli errori, puoi vedere <a href="https://forum.freecodecamp.org/t/advanced-node-and-express/567135#send-and-display-chat-messages-11" target="_blank" rel="noopener noreferrer nofollow">il progetto completato fino a questo punto</a>.
# --hints--

View File

@@ -8,13 +8,13 @@ dashedName: set-up-passport
# --description--
It's time to set up *Passport* so you can finally start allowing a user to register or log in to an account. In addition to Passport, you will use Express-session to handle sessions. Express-session has a ton of advanced features you can use, but for now you are just going to use the basics. Using this middleware saves the session id as a cookie in the client, and allows us to access the session data using that id on the server. This way, you keep personal account information out of the cookie used by the client to tell to your server clients are authenticated and keep the *key* to access the data stored on the server.
È ora di configurare *Passport* così da permettere finalmente a un utente di registrarsi o accedere a un account. In aggiunta a Passport, userai Express-session per gestire le sessioni. Express-session ha un sacco di funzionalità avanzate che puoi usare ma per ora userai solo le basi. Usare questo middleware salva l'id di sessione come cookie nel client e permette di accedere ai dati di sessione usando quell'id sul server. In questo modo, mantieni le informazioni personali dell'account al di fuori del cookie usato dal client per comunicare al tuo server di essere autenticato e tieni solo la *key* per accedere ai dati immagazzinati nel server.
`passport@~0.4.1` e `express-session@~1.17.1` sono già installati e sono entrambi elencati come dipendenze nel tuo file `package.json`.
You will need to set up the session settings and initialize Passport. First, create the variables `session` and `passport` to require `express-session` and `passport` respectively.
Dovrai configurare le impostazioni della sessione e inizializzare Passport. Per prima cosa, crea le variabili `session` e `passport` per richiedere rispettivamente `express-session` e `passport`.
Then, set up your Express app to use the session by defining the following options:
Poi, imposta la tua app Express in modo che utilizzi la sessione definendo le seguenti opzioni:
```javascript
app.use(session({
@@ -25,15 +25,15 @@ app.use(session({
}));
```
Be sure to add `SESSION_SECRET` to your `.env` file, and give it a random value. This is used to compute the hash used to encrypt your cookie!
Assicurati di aggiungere `SESSION_SECRET` al tuo file `.env` e dagli un valore casuale. Viene usato per calcolare l'hash utilizzato per crittografare il tuo cookie!
After you do all that, tell your express app to **use** `passport.initialize()` and `passport.session()`.
Dopo aver fatto tutto ciò, di' alla tua app express di **usare** `passport.initialize()` e `passport.session()`.
Submit your page when you think you've got it right. If you're running into errors, you can <a href="https://forum.freecodecamp.org/t/advanced-node-and-express/567135#set-up-passport-3" target="_blank" rel="noopener noreferrer nofollow">check out the project completed up to this point</a>.
Invia la tua pagina quando pensi che sia tutto corretto. Se incontri degli errori, puoi vedere <a href="https://forum.freecodecamp.org/t/advanced-node-and-express/567135#set-up-passport-3" target="_blank" rel="noopener noreferrer nofollow">il progetto completato fino a questo punto</a>.
# --hints--
Passport and Express-session should be dependencies.
Passaport e Express-session dovrebbero essere dipendenze.
```js
async (getUserInput) => {
@@ -53,7 +53,7 @@ async (getUserInput) => {
}
```
Dependencies should be correctly required.
Le dipendenze dovrebbero essere correttamente richieste.
```js
async (getUserInput) => {
@@ -73,7 +73,7 @@ async (getUserInput) => {
}
```
Express app should use new dependencies.
Express app dovrebbe utilizzare nuove dipendenze.
```js
async (getUserInput) => {
@@ -85,7 +85,7 @@ async (getUserInput) => {
}
```
Session and session secret should be correctly set up.
La sessione e il segreto di sessione dovrebbero essere impostate correttamente.
```js
async (getUserInput) => {

View File

@@ -18,9 +18,7 @@ dashedName: implementation-of-social-authentication
OAuth を使用したストラテジーでは、少なくとも*クライアント ID* と*クライアント シークレット*が必要です。サービスはこれらを使用して、認証リクエストが誰からのものか、またそれが有効かどうかを確認します。 これらは、認証を実装しようとしている GitHub などのサイトから取得され、アプリに固有のものです。これらの情報は**共有すべきではありません**。したがって、公開リポジトリにアップロードしたり、コード内に直接書き込んだりしないでください。 通常は、それらを `.env` ファイルに保存し、`process.env.GITHUB_CLIENT_ID` などのように参照します。 For this challenge you are going to use the GitHub strategy.
Follow these instructions to obtain your *Client ID and Secret* from GitHub. Go to your GitHub profile settings and click 'developer settings', then <a href="https://github.com/settings/developers" target="_blank" rel="noopener noreferrer nofollow">'OAuth Apps'</a>. Click 'New OAuth App', then give your app a name, paste in the URL to your Replit homepage (**Not the project code's url**) and, for the callback URL, paste in the same URL as the homepage but add `/auth/github/callback` to the end of it. This is where users will be redirected after authenticating on GitHub. After you do all that, click 'Register application'.
On the next page, click 'Generate a new client secret' to create a new client secret. Save the client ID and your client secret in your project's `.env` file as `GITHUB_CLIENT_ID` and `GITHUB_CLIENT_SECRET`.
Follow <a href="https://www.freecodecamp.org/news/how-to-set-up-a-github-oauth-application/" target="_blank" rel="noopener noreferrer nofollow">these instructions</a> to obtain your *Client ID and Secret* from GitHub. Set the homepage URL to your Replit homepage (**not the project code's URL**), and set the callback URL to the same homepage URL with `/auth/github/callback` appended to the end. Save the client ID and your client secret in your project's `.env` file as `GITHUB_CLIENT_ID` and `GITHUB_CLIENT_SECRET`.
In your `routes.js` file, add `showSocialAuth: true` to the homepage route, after `showRegistration: true`. Now, create 2 routes accepting GET requests: `/auth/github` and `/auth/github/callback`. The first should only call passport to authenticate `'github'`. The second should call passport to authenticate `'github'` with a failure redirect to `/`, and then if that is successful redirect to `/profile` (similar to your last project).

View File

@@ -26,11 +26,11 @@ As variáveis `a` e `b` pegam o primeiro e o segundo valores do array. Depois di
# --instructions--
Use a destructuring assignment with the rest parameter to emulate the behavior of `Array.prototype.slice()`. `removeFirstTwo()` should return a sub-array of the original array `list` with the first two elements omitted.
Use uma atribuição de desestruturação com o parâmetro rest para simular o comportamento de `Array.prototype.slice()`. `removeFirstTwo()` deve retornar um sub-array do array original `list` com os dois primeiros elementos omitidos.
# --hints--
`removeFirstTwo([1, 2, 3, 4, 5])` should be `[3, 4, 5]`
`removeFirstTwo([1, 2, 3, 4, 5])` deve retornar `[3, 4, 5]`
```js
const testArr_ = [1, 2, 3, 4, 5];
@@ -38,7 +38,7 @@ const testArrWORemoved_ = removeFirstTwo(testArr_);
assert(testArrWORemoved_.every((e, i) => e === i + 3) && testArrWORemoved_.length === 3);
```
`removeFirstTwo()` should not modify `list`
`removeFirstTwo()` não deve modificar `list`
```js
const testArr_ = [1, 2, 3, 4, 5];

View File

@@ -18,9 +18,7 @@ O caminho básico que este tipo de autenticação vai seguir em sua aplicação
As estratégias com OAuth exigem que você tenha, pelo menos, um *ID de client* e um *segredo de client*, que é uma maneira de o serviço verificar de quem está vindo o pedido de autenticação e se ele é válido. Estes são obtidos do site com o qual você está tentando implementar a autenticação, como o GitHub, e são exclusivos do seu aplicativo. **ELES NÃO DEVEM SER COMPARTILHADOS** e nunca devem ser enviados para um repositório público ou escritos diretamente no código. Uma prática comum é colocá-los no seu arquivo `.env` e referenciá-los assim: `process.env.GITHUB_CLIENT_ID`. Para este desafio, use a estratégia do GitHub.
Siga essas instruções para obter o *Client ID e o Segredo* do GitHub. Vá as configurações do seu perfil do GitHub e clique em 'developer settings' e <a href="https://github.com/settings/developers" target="_blank" rel="noopener noreferrer nofollow">'OAuth Apps'</a>. Clique em 'New OAuth App', nomeie sua aplicação, cole o URL de página inicial do Replit (**não o URL do código do projeto**) e, para o URL de callback, cole o mesmo URL da página inicial, mas adicione `/auth/github/callback` ao final dele. É para cá que os usuários serão redirecionados para a autenticação no GitHub. Depois de fazer tudo isso, clique em 'Register application'.
Na página seguinte, clique em 'Generate a new client secret' para criar um segredo de client. Salve o ID do client e seu segredo de client no arquivo `.env` do projeto como `GITHUB_CLIENT_ID` e `GITHUB_CLIENT_SECRET`.
Siga <a href="https://www.freecodecamp.org/news/how-to-set-up-a-github-oauth-application/" target="_blank" rel="noopener noreferrer nofollow">estas instruções</a> para obter seu *Client ID e Segredo* no GitHub. Defina o URL de sua página inicial como a página inicial do Replit (**não o URL do código do projeto**) e defina o URL de callback como o mesmo URL da página inicial com `/auth/github/callback` anexado ao final. Salve o ID do client e seu segredo de client no arquivo `.env` do projeto como `GITHUB_CLIENT_ID` e `GITHUB_CLIENT_SECRET`.
No seu arquivo `routes.js`, adicione `showSocialAuth: true` à rota da página inicial, após `showRegistration: true`. Agora, crie 2 rotas aceitando solicitações de GET: `/auth/github` e `/auth/github/callback`. O primeiro deve apenas chamar o Passport para autenticar o `'github'`. O segundo deve chamar o Passport para autenticar o `'github'` com um redirecionamento de falha para `/`. Então, se tiver sucesso, redirecionar para o `/profile` (semelhante ao último projeto).

View File

@@ -18,9 +18,7 @@ dashedName: implementation-of-social-authentication
Стратегії з OAuth потребують, щоб ви мали принаймні *Client ID* та *Client Secret*, так сервіс перевірить, від кого надходить запит автентифікації та чи є він дійсним. Вони отримані з сайту, з яким ви намагаєтеся здійснити автентифікацію, наприклад, з сайту GitHub і вони є унікальними для вашого застосунку **ВОНИ НЕ Є ДЛЯ ЗАГАЛЬНОГО ДОСТУПУ** і ніколи не повинні бути завантажені в публічне сховище або написані безпосередньо у вашому коді. Поширеною практикою є розміщення їх у файлі `.env` і посилання на них таким чином: `process.env.GITHUB_CLIENT_ID`. For this challenge you are going to use the GitHub strategy.
Follow these instructions to obtain your *Client ID and Secret* from GitHub. Go to your GitHub profile settings and click 'developer settings', then <a href="https://github.com/settings/developers" target="_blank" rel="noopener noreferrer nofollow">'OAuth Apps'</a>. Click 'New OAuth App', then give your app a name, paste in the URL to your Replit homepage (**Not the project code's url**) and, for the callback URL, paste in the same URL as the homepage but add `/auth/github/callback` to the end of it. This is where users will be redirected after authenticating on GitHub. After you do all that, click 'Register application'.
On the next page, click 'Generate a new client secret' to create a new client secret. Save the client ID and your client secret in your project's `.env` file as `GITHUB_CLIENT_ID` and `GITHUB_CLIENT_SECRET`.
Follow <a href="https://www.freecodecamp.org/news/how-to-set-up-a-github-oauth-application/" target="_blank" rel="noopener noreferrer nofollow">these instructions</a> to obtain your *Client ID and Secret* from GitHub. Set the homepage URL to your Replit homepage (**not the project code's URL**), and set the callback URL to the same homepage URL with `/auth/github/callback` appended to the end. Save the client ID and your client secret in your project's `.env` file as `GITHUB_CLIENT_ID` and `GITHUB_CLIENT_SECRET`.
In your `routes.js` file, add `showSocialAuth: true` to the homepage route, after `showRegistration: true`. Now, create 2 routes accepting GET requests: `/auth/github` and `/auth/github/callback`. The first should only call passport to authenticate `'github'`. The second should call passport to authenticate `'github'` with a failure redirect to `/`, and then if that is successful redirect to `/profile` (similar to your last project).