Permalink
Browse files

initial commit

  • Loading branch information...
david p
david p committed Dec 20, 2015
0 parents commit e0411946ffdf8706154977d33d9b13c4bd82c05b
Showing with 36,152 additions and 0 deletions.
  1. +23 −0 .env.example
  2. +3 −0 .gitattributes
  3. +5 −0 .gitignore
  4. +42 −0 app/App.php
  5. +43 −0 app/Auth.php
  6. +46 −0 app/Code.php
  7. +33 −0 app/Console/Commands/Inspire.php
  8. +30 −0 app/Console/Kernel.php
  9. +8 −0 app/Events/Event.php
  10. +51 −0 app/Exceptions/Handler.php
  11. +41 −0 app/Helpers/helpers.php
  12. +87 −0 app/Http/Controllers/AppController.php
  13. +65 −0 app/Http/Controllers/Auth/AuthController.php
  14. +32 −0 app/Http/Controllers/Auth/PasswordController.php
  15. +33 −0 app/Http/Controllers/AuthController.php
  16. +87 −0 app/Http/Controllers/CodeController.php
  17. +13 −0 app/Http/Controllers/Controller.php
  18. +83 −0 app/Http/Controllers/TelegramController.php
  19. +34 −0 app/Http/Controllers/TokenController.php
  20. +66 −0 app/Http/Controllers/UserController.php
  21. +33 −0 app/Http/Kernel.php
  22. +47 −0 app/Http/Middleware/Authenticate.php
  23. +17 −0 app/Http/Middleware/EncryptCookies.php
  24. +43 −0 app/Http/Middleware/RedirectIfAuthenticated.php
  25. +18 −0 app/Http/Middleware/VerifyCsrfToken.php
  26. +32 −0 app/Http/Requests/AuthRequest.php
  27. +30 −0 app/Http/Requests/LoginRequest.php
  28. +10 −0 app/Http/Requests/Request.php
  29. +26 −0 app/Http/routes.php
  30. +21 −0 app/Jobs/Job.php
  31. 0 app/Listeners/.gitkeep
  32. 0 app/Policies/.gitkeep
  33. +28 −0 app/Providers/AppServiceProvider.php
  34. +31 −0 app/Providers/AuthServiceProvider.php
  35. +33 −0 app/Providers/EventServiceProvider.php
  36. +44 −0 app/Providers/RouteServiceProvider.php
  37. +35 −0 app/Token.php
  38. +45 −0 app/User.php
  39. +51 −0 artisan
  40. +55 −0 bootstrap/app.php
  41. +34 −0 bootstrap/autoload.php
  42. +2 −0 bootstrap/cache/.gitignore
  43. +54 −0 composer.json
  44. +3,113 −0 composer.lock
  45. +198 −0 config/app.php
  46. +67 −0 config/auth.php
  47. +52 −0 config/broadcasting.php
  48. +79 −0 config/cache.php
  49. +35 −0 config/compile.php
  50. +127 −0 config/database.php
  51. +85 −0 config/filesystems.php
  52. +124 −0 config/mail.php
  53. +94 −0 config/queue.php
  54. +38 −0 config/services.php
  55. +153 −0 config/session.php
  56. +33 −0 config/view.php
  57. +1 −0 database/.gitignore
  58. +21 −0 database/factories/ModelFactory.php
  59. 0 database/migrations/.gitkeep
  60. +36 −0 database/migrations/2014_10_12_000000_create_users_table.php
  61. +39 −0 database/migrations/2015_12_19_213046_create_apps_table.php
  62. +36 −0 database/migrations/2015_12_19_213730_create_tokens_table.php
  63. +42 −0 database/migrations/2015_12_19_215502_create_auths_table.php
  64. +40 −0 database/migrations/2015_12_19_215627_create_codes_table.php
  65. 0 database/seeds/.gitkeep
  66. +21 −0 database/seeds/DatabaseSeeder.php
  67. +47 −0 database/seeds/UserTableSeeder.php
  68. +16 −0 gulpfile.js
  69. +10 −0 package.json
  70. +5 −0 phpspec.yml
  71. +27 −0 phpunit.xml
  72. +16 −0 public/.htaccess
  73. +18 −0 public/bower_components/angular/.bower.json
  74. +64 −0 public/bower_components/angular/README.md
  75. +21 −0 public/bower_components/angular/angular-csp.css
  76. +29,018 −0 public/bower_components/angular/angular.js
  77. +295 −0 public/bower_components/angular/angular.min.js
  78. BIN public/bower_components/angular/angular.min.js.gzip
  79. +8 −0 public/bower_components/angular/angular.min.js.map
  80. +8 −0 public/bower_components/angular/bower.json
  81. +2 −0 public/bower_components/angular/index.js
  82. +25 −0 public/bower_components/angular/package.json
  83. 0 public/favicon.ico
  84. +58 −0 public/index.php
  85. +10 −0 public/js/app.js
  86. +158 −0 public/js/config.js
  87. +2 −0 public/robots.txt
  88. +23 −0 public/web.config
  89. +27 −0 readme.md
  90. +2 −0 resources/assets/sass/app.scss
  91. +19 −0 resources/lang/en/auth.php
  92. +19 −0 resources/lang/en/pagination.php
  93. +22 −0 resources/lang/en/passwords.php
  94. +110 −0 resources/lang/en/validation.php
  95. +47 −0 resources/views/errors/503.blade.php
  96. 0 resources/views/vendor/.gitkeep
  97. +45 −0 resources/views/welcome.blade.php
  98. +21 −0 server.php
  99. +2 −0 storage/app/.gitignore
  100. +7 −0 storage/framework/.gitignore
  101. +2 −0 storage/framework/cache/.gitignore
  102. +2 −0 storage/framework/sessions/.gitignore
  103. +2 −0 storage/framework/views/.gitignore
  104. +2 −0 storage/logs/.gitignore
  105. +19 −0 tests/ExampleTest.php
  106. +25 −0 tests/TestCase.php
@@ -0,0 +1,23 @@
APP_ENV=local
APP_DEBUG=true
APP_KEY=SomeRandomString
DB_HOST=localhost
DB_DATABASE=homestead
DB_USERNAME=homestead
DB_PASSWORD=secret
CACHE_DRIVER=file
SESSION_DRIVER=file
QUEUE_DRIVER=sync
REDIS_HOST=localhost
REDIS_PASSWORD=null
REDIS_PORT=6379
MAIL_DRIVER=smtp
MAIL_HOST=mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null
@@ -0,0 +1,3 @@
* text=auto
*.css linguist-vendored
*.less linguist-vendored
@@ -0,0 +1,5 @@
/vendor
/node_modules
Homestead.yaml
Homestead.json
.env
@@ -0,0 +1,42 @@
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class App extends Model
{
/**
* The database table used by the model.
*
* @var string
*/
protected $table = 'apps';
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = ['user_id', 'name', 'redirect_url', 'client_id'];
/**
* The attributes excluded from the model's JSON form.
*
* @var array
*/
protected $hidden = [];
public static function findByClientId($clientId)
{
return App::where('client_id', '=', $clientId)
->firstOrFail();
}
public static function findByClientIdAndClientSecret($clientId, $clientSecret)
{
return App::where('client_id', '=', $clientId)
->where('client_secret', '=', $clientSecret)
->firstOrFail();
}
}
@@ -0,0 +1,43 @@
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class Auth extends Model
{
/**
* The database table used by the model.
*
* @var string
*/
protected $table = 'auths';
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = ['app_id', 'telegram_id', 'email', 'name',
'username'];
/**
* The attributes excluded from the model's JSON form.
*
* @var array
*/
protected $hidden = [];
public function app()
{
return $this->belongsTo('App\App');
}
public static function findByAppAndTelegramId($app, $telegramId)
{
return Auth::where('app_id', '=', $app->id)
->where('telegram_id', '=', $telegramId)
->firstOrFail();
}
}
@@ -0,0 +1,46 @@
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class Code extends Model
{
/**
* The database table used by the model.
*
* @var string
*/
protected $table = 'codes';
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = ['app_id', 'auth_id', 'code'];
/**
* The attributes excluded from the model's JSON form.
*
* @var array
*/
protected $hidden = [];
public function app()
{
return $this->belongsTo('App\App');
}
public function auth()
{
return $this->belongsTo('App\Auth');
}
public static function findByAppAndCode($app, $code)
{
return Code::where('app_id', '=', $app->id)
->where('code', '=', $code)
->firstOrFail();
}
}
@@ -0,0 +1,33 @@
<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
use Illuminate\Foundation\Inspiring;
class Inspire extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'inspire';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Display an inspiring quote';
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
$this->comment(PHP_EOL.Inspiring::quote().PHP_EOL);
}
}
@@ -0,0 +1,30 @@
<?php
namespace App\Console;
use Illuminate\Console\Scheduling\Schedule;
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
class Kernel extends ConsoleKernel
{
/**
* The Artisan commands provided by your application.
*
* @var array
*/
protected $commands = [
Commands\Inspire::class,
];
/**
* Define the application's command schedule.
*
* @param \Illuminate\Console\Scheduling\Schedule $schedule
* @return void
*/
protected function schedule(Schedule $schedule)
{
$schedule->command('inspire')
->hourly();
}
}
@@ -0,0 +1,8 @@
<?php
namespace App\Events;
abstract class Event
{
//
}
@@ -0,0 +1,51 @@
<?php
namespace App\Exceptions;
use Exception;
use Illuminate\Database\Eloquent\ModelNotFoundException;
use Symfony\Component\HttpKernel\Exception\HttpException;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
class Handler extends ExceptionHandler
{
/**
* A list of the exception types that should not be reported.
*
* @var array
*/
protected $dontReport = [
HttpException::class,
ModelNotFoundException::class,
];
/**
* Report or log an exception.
*
* This is a great spot to send exceptions to Sentry, Bugsnag, etc.
*
* @param \Exception $e
* @return void
*/
public function report(Exception $e)
{
return parent::report($e);
}
/**
* Render an exception into an HTTP response.
*
* @param \Illuminate\Http\Request $request
* @param \Exception $e
* @return \Illuminate\Http\Response
*/
public function render($request, Exception $e)
{
if ($e instanceof ModelNotFoundException) {
$e = new NotFoundHttpException($e->getMessage(), $e);
}
return parent::render($request, $e);
}
}
@@ -0,0 +1,41 @@
<?php
function generate_access_token() {
return 'A'.random_str(59);
}
function generate_token() {
return 'T'.random_str(59);
}
function generate_code() {
return 'C'.random_str(29);
}
function generate_client_id() {
return random_number(9);
}
function generate_client_secret() {
return random_str(20, '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ+-_=$/!#');
}
function random_str($length, $keyspace = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ')
{
$str = '';
$max = mb_strlen($keyspace, '8bit') - 1;
for ($i = 0; $i < $length; ++$i) {
$str .= $keyspace[random_int(0, $max)];
}
return $str;
}
function random_number($length, $keyspace = '0123456789')
{
$str = '';
$max = mb_strlen($keyspace, '8bit') - 1;
for ($i = 0; $i < $length; ++$i) {
$str .= $keyspace[random_int(0, $max)];
}
return intval($str);
}
Oops, something went wrong.

0 comments on commit e041194

Please sign in to comment.