public function run()
 {
     $owner = new Role();
     $owner->name = 'owner';
     $owner->display_name = 'Site Owner';
     $owner->description = 'User runs this instance of FF3';
     // optional
     $owner->save();
 }
Ejemplo n.º 2
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $user = User::create(['email' => '*****@*****.**', 'password' => bcrypt('james'), 'reset' => null, 'remember_token' => null]);
     User::create(['email' => '*****@*****.**', 'password' => bcrypt('james'), 'reset' => null, 'remember_token' => null]);
     $admin = Role::where('name', 'owner')->first();
     $user->attachRole($admin);
     // create asset accounts for user #1.
     TestData::createAssetAccounts($user);
     // create bills for user #1
     TestData::createBills($user);
     // create some budgets for user #1
     $this->createBudgets($user);
     // create some categories for user #1
     $this->createCategories($user);
     // create some piggy banks for user #1
     TestData::createPiggybanks($user);
     // create some expense accounts for user #1
     $this->createExpenseAccounts($user);
     // create some revenue accounts for user #1
     $this->createRevenueAccounts($user);
     // create journal + attachment:
     $this->createAttachments($user);
     // create opening balance for savings account:
     $this->openingBalanceSavings($user);
 }
Ejemplo n.º 3
0
 /**
  * @param User   $user
  * @param string $role
  *
  * @return bool
  */
 public function attachRole(User $user, string $role) : bool
 {
     $admin = Role::where('name', 'owner')->first();
     $user->attachRole($admin);
     $user->save();
     return true;
 }
Ejemplo n.º 4
0
 /**
  *
  */
 protected function createUsers()
 {
     User::create(['email' => '*****@*****.**', 'password' => bcrypt('james'), 'reset' => null, 'remember_token' => null]);
     $this->user = User::whereEmail('*****@*****.**')->first();
     // create rights:
     $role = Role::find(1);
     $this->user->roles()->save($role);
 }
Ejemplo n.º 5
0
 /**
  * Handle a registration request for the application.
  *
  * @param  Request $request
  *
  * @return \Illuminate\Http\RedirectResponse
  */
 public function postRegister(Request $request)
 {
     $validator = $this->validator($request->all());
     if ($validator->fails()) {
         $this->throwValidationException($request, $validator);
         // @codeCoverageIgnoreStart
     }
     // @codeCoverageIgnoreEnd
     $data = $request->all();
     $data['password'] = bcrypt($data['password']);
     Auth::login($this->create($data));
     // get the email address
     if (Auth::user() instanceof User) {
         $email = Auth::user()->email;
         $address = route('index');
         // send email.
         Mail::send(['emails.registered-html', 'emails.registered'], ['address' => $address], function (Message $message) use($email) {
             $message->to($email, $email)->subject('Welcome to Firefly III! ');
         });
         // set flash message
         Session::flash('success', 'You have registered successfully!');
         Session::flash('gaEventCategory', 'user');
         Session::flash('gaEventAction', 'new-registration');
         // first user ever?
         if (User::count() == 1) {
             $admin = Role::where('name', 'owner')->first();
             Auth::user()->attachRole($admin);
         }
         return redirect($this->redirectPath());
     }
     // @codeCoverageIgnoreStart
     abort(500, 'Not a user!');
     return redirect('/');
     // @codeCoverageIgnoreEnd
 }
Ejemplo n.º 6
0
 /**
  * Handle a registration request for the application.
  *
  * @param  \Illuminate\Http\Request $request
  *
  * @return \Illuminate\Http\Response
  */
 public function register(Request $request)
 {
     $validator = $this->validator($request->all());
     if ($validator->fails()) {
         $this->throwValidationException($request, $validator);
     }
     $data = $request->all();
     $data['password'] = bcrypt($data['password']);
     // is user email domain blocked?
     if ($this->isBlockedDomain($data['email'])) {
         $validator->getMessageBag()->add('email', (string) trans('validation.invalid_domain'));
         $this->throwValidationException($request, $validator);
     }
     Auth::login($this->create($request->all()));
     // get the email address
     if (Auth::user() instanceof User) {
         $email = Auth::user()->email;
         $address = route('index');
         $ipAddress = $request->ip();
         // send email.
         try {
             Mail::send(['emails.registered-html', 'emails.registered'], ['address' => $address, 'ip' => $ipAddress], function (Message $message) use($email) {
                 $message->to($email, $email)->subject('Welcome to Firefly III! ');
             });
         } catch (\Swift_TransportException $e) {
             Log::error($e->getMessage());
         }
         // set flash message
         Session::flash('success', 'You have registered successfully!');
         Session::flash('gaEventCategory', 'user');
         Session::flash('gaEventAction', 'new-registration');
         // first user ever?
         if (User::count() == 1) {
             $admin = Role::where('name', 'owner')->first();
             Auth::user()->attachRole($admin);
         }
         return redirect($this->redirectPath());
     }
     // @codeCoverageIgnoreStart
     abort(500, 'Not a user!');
     return redirect($this->redirectPath());
 }