G2A Many GEOs
SHARE
TWEET

Untitled

a guest Mar 30th, 2020 77 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // Parte express
  2. const express = require('express')
  3. const app = express()
  4. const mysql = require('mysql')
  5. const connection = mysql.createConnection({
  6.     host: 'localhost',
  7.     user: 'root',
  8.     database: 'auto'
  9. })
  10. const basicAuth = require('express-basic-auth')
  11.  
  12. connection.connect((error) => {
  13.     if (error) throw error
  14.     console.log('Avviato')
  15. })
  16.  
  17. app.use(basicAuth({
  18.     authorizer: asyncAuthorizer,
  19.     authorizeAsync: true,
  20.     challenge: true
  21. }))
  22.  
  23. function asyncAuthorizer(username, password, callback) {
  24.     connection.query('SELECT 1 FROM Users WHERE Username = ? AND Password = ?', [username, password], (error, results) => {
  25.         if (error) throw error
  26.         if (results.length > 0)
  27.             callback(null, true)
  28.         else
  29.             callback(null, false)
  30.     })
  31. }
  32.  
  33. app.get('/', (request, response) => {
  34.     response.send('OKK')
  35. })
  36.  
  37. app.listen(9090, (error) => {
  38.     if (error) throw error
  39.     console.log('Avviato su porta 9090')
  40. })
  41.  
  42. // Parte C#
  43. private ICredentials credentials = new NetworkCredential(); // Variabile globale della classe
  44. // Quando creo il WebClient setto le credenziali, es
  45.  using (var client = new WebClient())
  46.             {
  47.                 client.Credentials = credentials;
  48. // C'รจ un bottone per settare le credenziali:
  49. private void btnSet_Click(object sender, EventArgs e)
  50.         {
  51.             this.credentials = new NetworkCredential(txtUsername.Text, txtPassword.Text);
  52.         }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top