11 |
12 |
--------------------------------------------------------------------------------
/android/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/android/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/android/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 25
5 | buildToolsVersion "25.0.3"
6 | defaultConfig {
7 | applicationId "test.tuto_passport"
8 | minSdkVersion 16
9 | targetSdkVersion 25
10 | versionCode 1
11 | versionName "1.0"
12 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
13 | }
14 | buildTypes {
15 | release {
16 | minifyEnabled false
17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
18 | }
19 | }
20 | }
21 |
22 | dependencies {
23 | compile fileTree(dir: 'libs', include: ['*.jar'])
24 | androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
25 | exclude group: 'com.android.support', module: 'support-annotations'
26 | })
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 | compile 'com.android.support:appcompat-v7:25.3.1'
35 | compile 'com.android.support.constraint:constraint-layout:1.0.2'
36 | compile 'com.squareup.retrofit2:retrofit:2.3.0'
37 | compile 'com.squareup.retrofit2:converter-moshi:2.3.0'
38 | compile 'com.android.support:design:25.4.0'
39 | compile 'com.jakewharton:butterknife:8.6.0'
40 | compile 'com.basgeekball:awesome-validation:2.0'
41 | compile 'com.facebook.stetho:stetho:1.5.0'
42 | compile 'com.facebook.stetho:stetho-okhttp3:1.5.0'
43 | compile 'com.facebook.android:facebook-android-sdk:[4,5)'
44 | testCompile 'junit:junit:4.12'
45 | testCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.5.1'
46 | annotationProcessor 'com.jakewharton:butterknife-compiler:8.6.0'
47 | debugCompile 'com.squareup.leakcanary:leakcanary-android:1.5.1'
48 | releaseCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.5.1'
49 | }
50 |
--------------------------------------------------------------------------------
/android/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in E:\AndroidSDK/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
19 | # Uncomment this to preserve the line number information for
20 | # debugging stack traces.
21 | #-keepattributes SourceFile,LineNumberTable
22 |
23 | # If you keep the line number information, uncomment this to
24 | # hide the original source file name.
25 | #-renamesourcefileattribute SourceFile
26 |
--------------------------------------------------------------------------------
/android/app/src/androidTest/java/test/tuto_passport/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package test.tuto_passport;
2 |
3 | import android.content.Context;
4 | import android.support.test.InstrumentationRegistry;
5 | import android.support.test.runner.AndroidJUnit4;
6 |
7 | import org.junit.Test;
8 | import org.junit.runner.RunWith;
9 |
10 | import static org.junit.Assert.*;
11 |
12 | /**
13 | * Instrumentation test, which will execute on an Android device.
14 | *
15 | * @see Testing documentation
16 | */
17 | @RunWith(AndroidJUnit4.class)
18 | public class ExampleInstrumentedTest {
19 | @Test
20 | public void useAppContext() throws Exception {
21 | // Context of the app under test.
22 | Context appContext = InstrumentationRegistry.getTargetContext();
23 |
24 | assertEquals("test.tuto_passport", appContext.getPackageName());
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/android/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
15 |
17 |
18 |
19 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
--------------------------------------------------------------------------------
/android/app/src/main/java/test/tuto_passport/FacebookManager.java:
--------------------------------------------------------------------------------
1 | package test.tuto_passport;
2 |
3 | import android.app.Activity;
4 | import android.content.Intent;
5 | import android.os.Bundle;
6 |
7 | import com.facebook.AccessToken;
8 | import com.facebook.CallbackManager;
9 | import com.facebook.FacebookCallback;
10 | import com.facebook.FacebookException;
11 | import com.facebook.GraphRequest;
12 | import com.facebook.GraphResponse;
13 | import com.facebook.login.LoginManager;
14 | import com.facebook.login.LoginResult;
15 |
16 | import org.json.JSONException;
17 | import org.json.JSONObject;
18 |
19 | import java.util.Arrays;
20 |
21 | import retrofit2.Call;
22 | import retrofit2.Callback;
23 | import retrofit2.Response;
24 | import test.tuto_passport.network.ApiService;
25 |
26 | public class FacebookManager {
27 |
28 | private static final String TAG = "FacebookManager";
29 | private static final String PROVIDER = "facebook";
30 |
31 | public interface FacebookLoginListener{
32 | void onSuccess();
33 | void onError(String message);
34 | }
35 |
36 | private ApiService apiService;
37 | private TokenManager tokenManager;
38 | private CallbackManager callbackManager;
39 | private FacebookLoginListener listener;
40 | private Call call;
41 |
42 | private FacebookCallback facebookCallback = new FacebookCallback() {
43 | @Override
44 | public void onSuccess(LoginResult loginResult) {
45 | fetchUser(loginResult.getAccessToken());
46 | }
47 |
48 | @Override
49 | public void onCancel() {
50 |
51 | }
52 |
53 | @Override
54 | public void onError(FacebookException error) {
55 | listener.onError(error.getMessage());
56 | }
57 | };
58 |
59 | public FacebookManager(ApiService apiService, TokenManager tokenManager){
60 |
61 | this.apiService = apiService;
62 | this.tokenManager = tokenManager;
63 | this.callbackManager = CallbackManager.Factory.create();
64 | LoginManager.getInstance().registerCallback(callbackManager, facebookCallback);
65 |
66 | }
67 |
68 | public void login(Activity activity, FacebookLoginListener listener){
69 | this.listener = listener;
70 |
71 | if(AccessToken.getCurrentAccessToken() != null){
72 | //Get the user
73 | fetchUser(AccessToken.getCurrentAccessToken());
74 | }else{
75 | LoginManager.getInstance().logInWithReadPermissions(activity, Arrays.asList("public_profile", "email"));
76 | }
77 |
78 | }
79 |
80 | private void fetchUser(AccessToken accessToken){
81 | GraphRequest request = GraphRequest.newMeRequest(accessToken, new GraphRequest.GraphJSONObjectCallback() {
82 | @Override
83 | public void onCompleted(JSONObject object, GraphResponse response) {
84 |
85 | try {
86 | String id = object.getString("id");
87 | String name = object.getString("first_name");
88 | String email = object.getString("email");
89 | getTokenFromBackend(name, email, PROVIDER, id);
90 | } catch (JSONException e) {
91 | e.printStackTrace();
92 | listener.onError(e.getMessage());
93 | }
94 |
95 | }
96 | });
97 |
98 | Bundle parameters = new Bundle();
99 | parameters.putString("fields", "id, first_name, email");
100 | request.setParameters(parameters);
101 | request.executeAsync();
102 | }
103 |
104 | private void getTokenFromBackend(String name, String email, String provider, String providerUserId){
105 |
106 | call = apiService.socialAuth(name, email, provider, providerUserId);
107 | call.enqueue(new Callback() {
108 | @Override
109 | public void onResponse(Call call, Response response) {
110 | if(response.isSuccessful()){
111 | tokenManager.saveToken(response.body());
112 | listener.onSuccess();
113 | }else{
114 | listener.onError("An error occured");
115 | }
116 | }
117 |
118 | @Override
119 | public void onFailure(Call call, Throwable t) {
120 | listener.onError(t.getMessage());
121 | }
122 | });
123 |
124 | }
125 |
126 | public void onActivityResult(int requestCode, int resultCode, Intent data){
127 | callbackManager.onActivityResult(requestCode, resultCode, data);
128 | }
129 |
130 | public void onDestroy(){
131 | if(call != null){
132 | call.cancel();
133 | }
134 | call = null;
135 | if(callbackManager != null){
136 | LoginManager.getInstance().unregisterCallback(callbackManager);
137 | }
138 | }
139 |
140 | public void clearSession(){
141 | LoginManager.getInstance().logOut();
142 | }
143 | }
144 |
--------------------------------------------------------------------------------
/android/app/src/main/java/test/tuto_passport/LoginActivity.java:
--------------------------------------------------------------------------------
1 | package test.tuto_passport;
2 |
3 | import android.content.Intent;
4 | import android.support.design.widget.TextInputLayout;
5 | import android.support.transition.TransitionManager;
6 | import android.support.v7.app.AppCompatActivity;
7 | import android.os.Bundle;
8 | import android.util.Log;
9 | import android.util.Patterns;
10 | import android.view.View;
11 | import android.widget.LinearLayout;
12 | import android.widget.ProgressBar;
13 | import android.widget.RelativeLayout;
14 | import android.widget.Toast;
15 |
16 | import com.basgeekball.awesomevalidation.AwesomeValidation;
17 | import com.basgeekball.awesomevalidation.ValidationStyle;
18 | import com.basgeekball.awesomevalidation.utility.RegexTemplate;
19 |
20 | import java.util.List;
21 | import java.util.Map;
22 |
23 | import butterknife.BindView;
24 | import butterknife.ButterKnife;
25 | import butterknife.OnClick;
26 | import okhttp3.ResponseBody;
27 | import retrofit2.Call;
28 | import retrofit2.Callback;
29 | import retrofit2.Response;
30 | import retrofit2.http.POST;
31 | import test.tuto_passport.entities.AccessToken;
32 | import test.tuto_passport.entities.ApiError;
33 | import test.tuto_passport.network.ApiService;
34 | import test.tuto_passport.network.RetrofitBuilder;
35 |
36 | public class LoginActivity extends AppCompatActivity {
37 |
38 | private static final String TAG = "LoginActivity";
39 |
40 | @BindView(R.id.til_email)
41 | TextInputLayout tilEmail;
42 | @BindView(R.id.til_password)
43 | TextInputLayout tilPassword;
44 | @BindView(R.id.container)
45 | RelativeLayout container;
46 | @BindView(R.id.form_container)
47 | LinearLayout formContainer;
48 | @BindView(R.id.loader)
49 | ProgressBar loader;
50 |
51 | ApiService service;
52 | TokenManager tokenManager;
53 | AwesomeValidation validator;
54 | Call call;
55 | FacebookManager facebookManager;
56 |
57 | @Override
58 | protected void onCreate(Bundle savedInstanceState) {
59 | super.onCreate(savedInstanceState);
60 | setContentView(R.layout.activity_login);
61 |
62 | ButterKnife.bind(this);
63 |
64 | service = RetrofitBuilder.createService(ApiService.class);
65 | tokenManager = TokenManager.getInstance(getSharedPreferences("prefs", MODE_PRIVATE));
66 | validator = new AwesomeValidation(ValidationStyle.TEXT_INPUT_LAYOUT);
67 | facebookManager = new FacebookManager(service, tokenManager);
68 | setupRules();
69 |
70 | if(tokenManager.getToken().getAccessToken() != null){
71 | startActivity(new Intent(LoginActivity.this, PostActivity.class));
72 | finish();
73 | }
74 | }
75 |
76 | private void showLoading(){
77 | TransitionManager.beginDelayedTransition(container);
78 | formContainer.setVisibility(View.GONE);
79 | loader.setVisibility(View.VISIBLE);
80 | }
81 |
82 | private void showForm(){
83 | TransitionManager.beginDelayedTransition(container);
84 | formContainer.setVisibility(View.VISIBLE);
85 | loader.setVisibility(View.GONE);
86 | }
87 |
88 | @OnClick(R.id.btn_facebook)
89 | void loginFacebook(){
90 | showLoading();
91 | facebookManager.login(this, new FacebookManager.FacebookLoginListener() {
92 | @Override
93 | public void onSuccess() {
94 | facebookManager.clearSession();
95 | startActivity(new Intent(LoginActivity.this, PostActivity.class));
96 | finish();
97 | }
98 |
99 | @Override
100 | public void onError(String message) {
101 | showForm();
102 | Toast.makeText(LoginActivity.this, message, Toast.LENGTH_SHORT).show();
103 | }
104 | });
105 |
106 | }
107 |
108 | @OnClick(R.id.btn_login)
109 | void login() {
110 |
111 | String email = tilEmail.getEditText().getText().toString();
112 | String password = tilPassword.getEditText().getText().toString();
113 |
114 | tilEmail.setError(null);
115 | tilPassword.setError(null);
116 |
117 | validator.clear();
118 |
119 | if (validator.validate()) {
120 | showLoading();
121 | call = service.login(email, password);
122 | call.enqueue(new Callback() {
123 | @Override
124 | public void onResponse(Call call, Response response) {
125 |
126 | Log.w(TAG, "onResponse: " + response);
127 |
128 | if (response.isSuccessful()) {
129 | tokenManager.saveToken(response.body());
130 | startActivity(new Intent(LoginActivity.this, PostActivity.class));
131 | finish();
132 | } else {
133 | if (response.code() == 422) {
134 | handleErrors(response.errorBody());
135 | }
136 | if (response.code() == 401) {
137 | ApiError apiError = Utils.converErrors(response.errorBody());
138 | Toast.makeText(LoginActivity.this, apiError.getMessage(), Toast.LENGTH_LONG).show();
139 | }
140 | showForm();
141 | }
142 |
143 | }
144 |
145 | @Override
146 | public void onFailure(Call call, Throwable t) {
147 | Log.w(TAG, "onFailure: " + t.getMessage());
148 | showForm();
149 | }
150 | });
151 |
152 | }
153 |
154 | }
155 |
156 | @OnClick(R.id.go_to_register)
157 | void goToRegister(){
158 | startActivity(new Intent(LoginActivity.this, RegisterActivity.class));
159 | }
160 |
161 | private void handleErrors(ResponseBody response) {
162 |
163 | ApiError apiError = Utils.converErrors(response);
164 |
165 | for (Map.Entry> error : apiError.getErrors().entrySet()) {
166 | if (error.getKey().equals("username")) {
167 | tilEmail.setError(error.getValue().get(0));
168 | }
169 | if (error.getKey().equals("password")) {
170 | tilPassword.setError(error.getValue().get(0));
171 | }
172 | }
173 |
174 | }
175 |
176 | public void setupRules() {
177 |
178 | validator.addValidation(this, R.id.til_email, Patterns.EMAIL_ADDRESS, R.string.err_email);
179 | validator.addValidation(this, R.id.til_password, RegexTemplate.NOT_EMPTY, R.string.err_password);
180 | }
181 |
182 | @Override
183 | protected void onActivityResult(int requestCode, int resultCode, Intent data) {
184 | super.onActivityResult(requestCode, resultCode, data);
185 | facebookManager.onActivityResult(requestCode, resultCode, data);
186 | }
187 |
188 | @Override
189 | protected void onDestroy() {
190 | super.onDestroy();
191 | if (call != null) {
192 | call.cancel();
193 | call = null;
194 | }
195 | facebookManager.onDestroy();
196 | }
197 | }
198 |
--------------------------------------------------------------------------------
/android/app/src/main/java/test/tuto_passport/MyApp.java:
--------------------------------------------------------------------------------
1 | package test.tuto_passport;
2 |
3 | import android.app.Application;
4 |
5 | import com.facebook.stetho.Stetho;
6 | import com.squareup.leakcanary.LeakCanary;
7 |
8 | public class MyApp extends Application {
9 |
10 | @Override
11 | public void onCreate() {
12 | super.onCreate();
13 | Stetho.initializeWithDefaults(this);
14 |
15 | // if (LeakCanary.isInAnalyzerProcess(this)) {
16 | // // This process is dedicated to LeakCanary for heap analysis.
17 | // // You should not init your app in this process.
18 | // return;
19 | // }
20 | // LeakCanary.install(this);
21 | // Normal app init code...
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/android/app/src/main/java/test/tuto_passport/PostActivity.java:
--------------------------------------------------------------------------------
1 | package test.tuto_passport;
2 |
3 | import android.content.Intent;
4 | import android.support.v7.app.AppCompatActivity;
5 | import android.os.Bundle;
6 | import android.util.Log;
7 | import android.widget.TextView;
8 |
9 | import butterknife.BindView;
10 | import butterknife.ButterKnife;
11 | import butterknife.OnClick;
12 | import retrofit2.Call;
13 | import retrofit2.Callback;
14 | import retrofit2.Response;
15 | import test.tuto_passport.entities.PostResponse;
16 | import test.tuto_passport.network.ApiService;
17 | import test.tuto_passport.network.RetrofitBuilder;
18 |
19 | public class PostActivity extends AppCompatActivity {
20 |
21 | private static final String TAG = "PostActivity";
22 |
23 | @BindView(R.id.post_title)
24 | TextView title;
25 |
26 | ApiService service;
27 | TokenManager tokenManager;
28 | Call call;
29 |
30 |
31 | @Override
32 | protected void onCreate(Bundle savedInstanceState) {
33 | super.onCreate(savedInstanceState);
34 | setContentView(R.layout.activity_post);
35 |
36 | ButterKnife.bind(this);
37 | tokenManager = TokenManager.getInstance(getSharedPreferences("prefs", MODE_PRIVATE));
38 |
39 | if(tokenManager.getToken() == null){
40 | startActivity(new Intent(PostActivity.this, LoginActivity.class));
41 | finish();
42 | }
43 |
44 | service = RetrofitBuilder.createServiceWithAuth(ApiService.class, tokenManager);
45 | }
46 |
47 | @OnClick(R.id.btn_posts)
48 | void getPosts(){
49 |
50 | call = service.posts();
51 | call.enqueue(new Callback() {
52 | @Override
53 | public void onResponse(Call call, Response response) {
54 | Log.w(TAG, "onResponse: " + response );
55 |
56 | if(response.isSuccessful()){
57 | title.setText(response.body().getData().get(0).getTitle());
58 | }else {
59 | tokenManager.deleteToken();
60 | startActivity(new Intent(PostActivity.this, LoginActivity.class));
61 | finish();
62 |
63 | }
64 | }
65 |
66 | @Override
67 | public void onFailure(Call call, Throwable t) {
68 | Log.w(TAG, "onFailure: " + t.getMessage() );
69 | }
70 | });
71 |
72 | }
73 |
74 | @Override
75 | protected void onDestroy() {
76 | super.onDestroy();
77 | if(call != null){
78 | call.cancel();
79 | call = null;
80 | }
81 | }
82 | }
83 |
--------------------------------------------------------------------------------
/android/app/src/main/java/test/tuto_passport/RegisterActivity.java:
--------------------------------------------------------------------------------
1 | package test.tuto_passport;
2 |
3 | import android.content.Intent;
4 | import android.support.design.widget.TextInputLayout;
5 | import android.support.v7.app.AppCompatActivity;
6 | import android.os.Bundle;
7 | import android.util.Log;
8 | import android.util.Patterns;
9 |
10 | import com.basgeekball.awesomevalidation.AwesomeValidation;
11 | import com.basgeekball.awesomevalidation.ValidationStyle;
12 | import com.basgeekball.awesomevalidation.utility.RegexTemplate;
13 |
14 | import java.io.IOException;
15 | import java.lang.annotation.Annotation;
16 | import java.util.List;
17 | import java.util.Map;
18 |
19 | import butterknife.BindView;
20 | import butterknife.ButterKnife;
21 | import butterknife.OnClick;
22 | import okhttp3.ResponseBody;
23 | import retrofit2.Call;
24 | import retrofit2.Callback;
25 | import retrofit2.Converter;
26 | import retrofit2.Response;
27 | import test.tuto_passport.entities.AccessToken;
28 | import test.tuto_passport.entities.ApiError;
29 | import test.tuto_passport.network.ApiService;
30 | import test.tuto_passport.network.RetrofitBuilder;
31 |
32 | public class RegisterActivity extends AppCompatActivity {
33 |
34 | private static final String TAG = "RegisterActivity";
35 |
36 | @BindView(R.id.til_name)
37 | TextInputLayout tilName;
38 | @BindView(R.id.til_email)
39 | TextInputLayout tilEmail;
40 | @BindView(R.id.til_password)
41 | TextInputLayout tilPassword;
42 |
43 | ApiService service;
44 | Call call;
45 | AwesomeValidation validator;
46 | TokenManager tokenManager;
47 |
48 | @Override
49 | protected void onCreate(Bundle savedInstanceState) {
50 | super.onCreate(savedInstanceState);
51 | setContentView(R.layout.activity_register);
52 |
53 | ButterKnife.bind(this);
54 |
55 | service = RetrofitBuilder.createService(ApiService.class);
56 | validator = new AwesomeValidation(ValidationStyle.TEXT_INPUT_LAYOUT);
57 | tokenManager = TokenManager.getInstance(getSharedPreferences("prefs", MODE_PRIVATE));
58 | setupRules();
59 |
60 | if(tokenManager.getToken().getAccessToken() != null){
61 | startActivity(new Intent(RegisterActivity.this, PostActivity.class));
62 | finish();
63 | }
64 | }
65 |
66 | @OnClick(R.id.btn_register)
67 | void register(){
68 |
69 | String name = tilName.getEditText().getText().toString();
70 | String email = tilEmail.getEditText().getText().toString();
71 | String password = tilPassword.getEditText().getText().toString();
72 |
73 | tilName.setError(null);
74 | tilEmail.setError(null);
75 | tilPassword.setError(null);
76 |
77 | validator.clear();
78 |
79 | if(validator.validate()) {
80 | call = service.register(name, email, password);
81 | call.enqueue(new Callback() {
82 | @Override
83 | public void onResponse(Call call, Response response) {
84 |
85 | Log.w(TAG, "onResponse: " + response);
86 |
87 | if (response.isSuccessful()) {
88 | Log.w(TAG, "onResponse: " + response.body() );
89 | tokenManager.saveToken(response.body());
90 | startActivity(new Intent(RegisterActivity.this, PostActivity.class));
91 | finish();
92 | } else {
93 | handleErrors(response.errorBody());
94 | }
95 |
96 | }
97 |
98 | @Override
99 | public void onFailure(Call call, Throwable t) {
100 | Log.w(TAG, "onFailure: " + t.getMessage());
101 | }
102 | });
103 | }
104 | }
105 |
106 | @OnClick(R.id.go_to_login)
107 | void goToRegister(){
108 | startActivity(new Intent(RegisterActivity.this, LoginActivity.class));
109 | }
110 |
111 |
112 | private void handleErrors(ResponseBody response){
113 |
114 | ApiError apiError = Utils.converErrors(response);
115 |
116 | for(Map.Entry> error : apiError.getErrors().entrySet()){
117 | if(error.getKey().equals("name")){
118 | tilName.setError(error.getValue().get(0));
119 | }
120 | if(error.getKey().equals("email")){
121 | tilEmail.setError(error.getValue().get(0));
122 | }
123 | if(error.getKey().equals("password")){
124 | tilPassword.setError(error.getValue().get(0));
125 | }
126 | }
127 |
128 | }
129 |
130 | public void setupRules(){
131 |
132 | validator.addValidation(this, R.id.til_name, RegexTemplate.NOT_EMPTY, R.string.err_name);
133 | validator.addValidation(this, R.id.til_email, Patterns.EMAIL_ADDRESS, R.string.err_email);
134 | validator.addValidation(this, R.id.til_password, "[a-zA-Z0-9]{6,}", R.string.err_password);
135 | }
136 |
137 | @Override
138 | protected void onDestroy() {
139 | super.onDestroy();
140 | if(call != null) {
141 | call.cancel();
142 | call = null;
143 | }
144 | }
145 | }
146 |
--------------------------------------------------------------------------------
/android/app/src/main/java/test/tuto_passport/TokenManager.java:
--------------------------------------------------------------------------------
1 | package test.tuto_passport;
2 |
3 | import android.content.SharedPreferences;
4 |
5 | import test.tuto_passport.entities.AccessToken;
6 |
7 | public class TokenManager {
8 |
9 | private SharedPreferences prefs;
10 | private SharedPreferences.Editor editor;
11 |
12 | private static TokenManager INSTANCE = null;
13 |
14 | private TokenManager(SharedPreferences prefs){
15 | this.prefs = prefs;
16 | this.editor = prefs.edit();
17 | }
18 |
19 | static synchronized TokenManager getInstance(SharedPreferences prefs){
20 | if(INSTANCE == null){
21 | INSTANCE = new TokenManager(prefs);
22 | }
23 | return INSTANCE;
24 | }
25 |
26 | public void saveToken(AccessToken token){
27 | editor.putString("ACCESS_TOKEN", token.getAccessToken()).commit();
28 | editor.putString("REFRESH_TOKEN", token.getRefreshToken()).commit();
29 | }
30 |
31 | public void deleteToken(){
32 | editor.remove("ACCESS_TOKEN").commit();
33 | editor.remove("REFRESH_TOKEN").commit();
34 | }
35 |
36 | public AccessToken getToken(){
37 | AccessToken token = new AccessToken();
38 | token.setAccessToken(prefs.getString("ACCESS_TOKEN", null));
39 | token.setRefreshToken(prefs.getString("REFRESH_TOKEN", null));
40 | return token;
41 | }
42 |
43 |
44 |
45 | }
46 |
--------------------------------------------------------------------------------
/android/app/src/main/java/test/tuto_passport/Utils.java:
--------------------------------------------------------------------------------
1 | package test.tuto_passport;
2 |
3 | import java.io.IOException;
4 | import java.lang.annotation.Annotation;
5 |
6 | import okhttp3.ResponseBody;
7 | import retrofit2.Converter;
8 | import test.tuto_passport.entities.ApiError;
9 | import test.tuto_passport.network.RetrofitBuilder;
10 |
11 | public class Utils {
12 |
13 | public static ApiError converErrors(ResponseBody response){
14 | Converter converter = RetrofitBuilder.getRetrofit().responseBodyConverter(ApiError.class, new Annotation[0]);
15 |
16 | ApiError apiError = null;
17 |
18 | try {
19 | apiError = converter.convert(response);
20 | } catch (IOException e) {
21 | e.printStackTrace();
22 | }
23 | return apiError;
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/android/app/src/main/java/test/tuto_passport/entities/AccessToken.java:
--------------------------------------------------------------------------------
1 | package test.tuto_passport.entities;
2 |
3 | import com.squareup.moshi.Json;
4 |
5 | public class AccessToken {
6 |
7 | @Json(name = "token_type")
8 | String tokenType;
9 | @Json(name = "expires_in")
10 | int expiresIn;
11 | @Json(name = "access_token")
12 | String accessToken;
13 | @Json(name = "refresh_token")
14 | String refreshToken;
15 |
16 | public String getTokenType() {
17 | return tokenType;
18 | }
19 |
20 | public int getExpiresIn() {
21 | return expiresIn;
22 | }
23 |
24 | public String getAccessToken() {
25 | return accessToken;
26 | }
27 |
28 | public String getRefreshToken() {
29 | return refreshToken;
30 | }
31 |
32 | public void setTokenType(String tokenType) {
33 | this.tokenType = tokenType;
34 | }
35 |
36 | public void setExpiresIn(int expiresIn) {
37 | this.expiresIn = expiresIn;
38 | }
39 |
40 | public void setAccessToken(String accessToken) {
41 | this.accessToken = accessToken;
42 | }
43 |
44 | public void setRefreshToken(String refreshToken) {
45 | this.refreshToken = refreshToken;
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/android/app/src/main/java/test/tuto_passport/entities/ApiError.java:
--------------------------------------------------------------------------------
1 | package test.tuto_passport.entities;
2 |
3 | import com.squareup.moshi.Json;
4 |
5 | import java.util.List;
6 | import java.util.Map;
7 |
8 | public class ApiError {
9 |
10 | String message;
11 | Map> errors;
12 |
13 | public String getMessage() {
14 | return message;
15 | }
16 |
17 | public Map> getErrors() {
18 | return errors;
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/android/app/src/main/java/test/tuto_passport/entities/Post.java:
--------------------------------------------------------------------------------
1 | package test.tuto_passport.entities;
2 |
3 | public class Post {
4 |
5 | int id;
6 | String title;
7 | String body;
8 |
9 | public int getId() {
10 | return id;
11 | }
12 |
13 | public void setId(int id) {
14 | this.id = id;
15 | }
16 |
17 | public String getTitle() {
18 | return title;
19 | }
20 |
21 | public void setTitle(String title) {
22 | this.title = title;
23 | }
24 |
25 | public String getBody() {
26 | return body;
27 | }
28 |
29 | public void setBody(String body) {
30 | this.body = body;
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/android/app/src/main/java/test/tuto_passport/entities/PostResponse.java:
--------------------------------------------------------------------------------
1 | package test.tuto_passport.entities;
2 |
3 | import java.util.List;
4 |
5 | public class PostResponse {
6 |
7 | List data;
8 |
9 | public List getData() {
10 | return data;
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/android/app/src/main/java/test/tuto_passport/network/ApiService.java:
--------------------------------------------------------------------------------
1 | package test.tuto_passport.network;
2 |
3 | import retrofit2.Call;
4 | import retrofit2.http.Field;
5 | import retrofit2.http.FormUrlEncoded;
6 | import retrofit2.http.GET;
7 | import retrofit2.http.POST;
8 | import test.tuto_passport.entities.AccessToken;
9 | import test.tuto_passport.entities.PostResponse;
10 |
11 | public interface ApiService {
12 |
13 | @POST("register")
14 | @FormUrlEncoded
15 | Call register(@Field("name") String name, @Field("email") String email, @Field("password") String password);
16 |
17 | @POST("login")
18 | @FormUrlEncoded
19 | Call login(@Field("username") String username, @Field("password") String password);
20 |
21 | @POST("social_auth")
22 | @FormUrlEncoded
23 | Call socialAuth(@Field("name") String name,
24 | @Field("email") String email,
25 | @Field("provider") String provider,
26 | @Field("provider_user_id") String providerUserId);
27 |
28 | @POST("refresh")
29 | @FormUrlEncoded
30 | Call refresh(@Field("refresh_token") String refreshToken);
31 |
32 | @GET("posts")
33 | Call posts();
34 |
35 | }
36 |
--------------------------------------------------------------------------------
/android/app/src/main/java/test/tuto_passport/network/CustomAuthenticator.java:
--------------------------------------------------------------------------------
1 | package test.tuto_passport.network;
2 |
3 | import java.io.IOException;
4 |
5 | import javax.annotation.Nullable;
6 |
7 | import okhttp3.Authenticator;
8 | import okhttp3.Request;
9 | import okhttp3.Response;
10 | import okhttp3.Route;
11 | import retrofit2.Call;
12 | import test.tuto_passport.TokenManager;
13 | import test.tuto_passport.entities.AccessToken;
14 |
15 | public class CustomAuthenticator implements Authenticator {
16 |
17 | private TokenManager tokenManager;
18 | private static CustomAuthenticator INSTANCE;
19 |
20 | private CustomAuthenticator(TokenManager tokenManager){
21 | this.tokenManager = tokenManager;
22 | }
23 |
24 | static synchronized CustomAuthenticator getInstance(TokenManager tokenManager){
25 | if(INSTANCE == null){
26 | INSTANCE = new CustomAuthenticator(tokenManager);
27 | }
28 |
29 | return INSTANCE;
30 | }
31 |
32 |
33 | @Nullable
34 | @Override
35 | public Request authenticate(Route route, Response response) throws IOException {
36 |
37 | if(responseCount(response) >= 3){
38 | return null;
39 | }
40 |
41 | AccessToken token = tokenManager.getToken();
42 |
43 | ApiService service = RetrofitBuilder.createService(ApiService.class);
44 | Call call = service.refresh(token.getRefreshToken() + "a");
45 | retrofit2.Response res = call.execute();
46 |
47 | if(res.isSuccessful()){
48 | AccessToken newToken = res.body();
49 | tokenManager.saveToken(newToken);
50 |
51 | return response.request().newBuilder().header("Authorization", "Bearer " + res.body().getAccessToken()).build();
52 | }else{
53 | return null;
54 | }
55 | }
56 |
57 | private int responseCount(Response response) {
58 | int result = 1;
59 | while ((response = response.priorResponse()) != null) {
60 | result++;
61 | }
62 | return result;
63 | }
64 | }
65 |
--------------------------------------------------------------------------------
/android/app/src/main/java/test/tuto_passport/network/RetrofitBuilder.java:
--------------------------------------------------------------------------------
1 | package test.tuto_passport.network;
2 |
3 | import com.facebook.stetho.okhttp3.StethoInterceptor;
4 |
5 | import java.io.IOException;
6 |
7 | import okhttp3.Interceptor;
8 | import okhttp3.OkHttpClient;
9 | import okhttp3.Request;
10 | import okhttp3.Response;
11 | import retrofit2.Retrofit;
12 | import retrofit2.converter.moshi.MoshiConverterFactory;
13 | import test.tuto_passport.BuildConfig;
14 | import test.tuto_passport.TokenManager;
15 |
16 | public class RetrofitBuilder {
17 |
18 | private static final String BASE_URL = "http://192.168.0.10/tutos/tuto_passport/public/api/";
19 |
20 | private final static OkHttpClient client = buildClient();
21 | private final static Retrofit retrofit = buildRetrofit(client);
22 |
23 | private static OkHttpClient buildClient(){
24 | OkHttpClient.Builder builder = new OkHttpClient.Builder()
25 | .addInterceptor(new Interceptor() {
26 | @Override
27 | public Response intercept(Chain chain) throws IOException {
28 | Request request = chain.request();
29 |
30 | Request.Builder builder = request.newBuilder()
31 | .addHeader("Accept", "application/json")
32 | .addHeader("Connection", "close");
33 |
34 | request = builder.build();
35 |
36 | return chain.proceed(request);
37 |
38 | }
39 | });
40 |
41 | if(BuildConfig.DEBUG){
42 | builder.addNetworkInterceptor(new StethoInterceptor());
43 | }
44 |
45 | return builder.build();
46 |
47 | }
48 |
49 | private static Retrofit buildRetrofit(OkHttpClient client){
50 | return new Retrofit.Builder()
51 | .baseUrl(BASE_URL)
52 | .client(client)
53 | .addConverterFactory(MoshiConverterFactory.create())
54 | .build();
55 | }
56 |
57 | public static T createService(Class service){
58 | return retrofit.create(service);
59 | }
60 |
61 | public static T createServiceWithAuth(Class service, final TokenManager tokenManager){
62 |
63 | OkHttpClient newClient = client.newBuilder().addInterceptor(new Interceptor() {
64 | @Override
65 | public Response intercept(Chain chain) throws IOException {
66 |
67 | Request request = chain.request();
68 |
69 | Request.Builder builder = request.newBuilder();
70 |
71 | if(tokenManager.getToken().getAccessToken() != null){
72 | builder.addHeader("Authorization", "Bearer " + tokenManager.getToken().getAccessToken());
73 | }
74 | request = builder.build();
75 | return chain.proceed(request);
76 | }
77 | }).authenticator(CustomAuthenticator.getInstance(tokenManager)).build();
78 |
79 | Retrofit newRetrofit = retrofit.newBuilder().client(newClient).build();
80 | return newRetrofit.create(service);
81 |
82 | }
83 |
84 | public static Retrofit getRetrofit() {
85 | return retrofit;
86 | }
87 | }
88 |
--------------------------------------------------------------------------------
/android/app/src/main/res/drawable/email_icon.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/android/app/src/main/res/drawable/facebook_icon.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/android/app/src/main/res/drawable/facebook_icon_dark.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/android/app/src/main/res/drawable/facebook_selector.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/android/app/src/main/res/drawable/lock_icon.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/android/app/src/main/res/drawable/person_icon.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/android/app/src/main/res/layout/activity_login.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
11 |
17 |
18 |
24 |
25 |
31 |
32 |
38 |
39 |
40 |
45 |
46 |
54 |
55 |
56 |
57 |
63 |
64 |
73 |
74 |
75 |
76 |
77 |
86 |
87 |
94 |
95 |
96 |
97 |
98 |
99 |
--------------------------------------------------------------------------------
/android/app/src/main/res/layout/activity_post.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
18 |
19 |
29 |
30 |
31 |
--------------------------------------------------------------------------------
/android/app/src/main/res/layout/activity_register.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
14 |
15 |
21 |
22 |
27 |
28 |
38 |
39 |
40 |
41 |
46 |
47 |
55 |
56 |
57 |
58 |
64 |
65 |
74 |
75 |
76 |
77 |
78 |
87 |
88 |
95 |
96 |
102 |
103 |
104 |
105 |
106 |
107 |
--------------------------------------------------------------------------------
/android/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ProgrammationAndroid/Laravel-Passport-Android/305b910590216eb16c3d913c0c7a536ac05ea068/android/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ProgrammationAndroid/Laravel-Passport-Android/305b910590216eb16c3d913c0c7a536ac05ea068/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/android/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ProgrammationAndroid/Laravel-Passport-Android/305b910590216eb16c3d913c0c7a536ac05ea068/android/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ProgrammationAndroid/Laravel-Passport-Android/305b910590216eb16c3d913c0c7a536ac05ea068/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ProgrammationAndroid/Laravel-Passport-Android/305b910590216eb16c3d913c0c7a536ac05ea068/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ProgrammationAndroid/Laravel-Passport-Android/305b910590216eb16c3d913c0c7a536ac05ea068/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ProgrammationAndroid/Laravel-Passport-Android/305b910590216eb16c3d913c0c7a536ac05ea068/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ProgrammationAndroid/Laravel-Passport-Android/305b910590216eb16c3d913c0c7a536ac05ea068/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ProgrammationAndroid/Laravel-Passport-Android/305b910590216eb16c3d913c0c7a536ac05ea068/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ProgrammationAndroid/Laravel-Passport-Android/305b910590216eb16c3d913c0c7a536ac05ea068/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/android/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #3b3b3b
4 | #232323
5 | #ff7c48
6 | #ff3737
7 |
8 |
--------------------------------------------------------------------------------
/android/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | Tuto_Passport
3 |
4 |
5 | The name field is required.
6 | The email must be a valid email address.
7 | The password must be at least 6 characters.
8 |
9 | YOUR_APP_ID
10 | YOUR_THING
11 |
12 |
--------------------------------------------------------------------------------
/android/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
11 |
12 |
--------------------------------------------------------------------------------
/android/app/src/test/java/test/tuto_passport/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package test.tuto_passport;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.*;
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * @see Testing documentation
11 | */
12 | public class ExampleUnitTest {
13 | @Test
14 | public void addition_isCorrect() throws Exception {
15 | assertEquals(4, 2 + 2);
16 | }
17 | }
--------------------------------------------------------------------------------
/android/build.gradle:
--------------------------------------------------------------------------------
1 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
2 |
3 | buildscript {
4 | repositories {
5 | jcenter()
6 | }
7 | dependencies {
8 | classpath 'com.android.tools.build:gradle:2.3.2'
9 |
10 | // NOTE: Do not place your application dependencies here; they belong
11 | // in the individual module build.gradle files
12 | }
13 | }
14 |
15 | allprojects {
16 | repositories {
17 | jcenter()
18 | maven {
19 | url "https://maven.google.com"
20 | }
21 | }
22 | }
23 |
24 | task clean(type: Delete) {
25 | delete rootProject.buildDir
26 | }
27 |
--------------------------------------------------------------------------------
/android/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 |
3 | # IDE (e.g. Android Studio) users:
4 | # Gradle settings configured through the IDE *will override*
5 | # any settings specified in this file.
6 |
7 | # For more details on how to configure your build environment visit
8 | # http://www.gradle.org/docs/current/userguide/build_environment.html
9 |
10 | # Specifies the JVM arguments used for the daemon process.
11 | # The setting is particularly useful for tweaking memory settings.
12 | org.gradle.jvmargs=-Xmx1536m
13 |
14 | # When configured, Gradle will run in incubating parallel mode.
15 | # This option should only be used with decoupled projects. More details, visit
16 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
17 | # org.gradle.parallel=true
18 |
--------------------------------------------------------------------------------
/android/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ProgrammationAndroid/Laravel-Passport-Android/305b910590216eb16c3d913c0c7a536ac05ea068/android/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/android/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Mon Jun 19 17:48:46 CEST 2017
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip
7 |
--------------------------------------------------------------------------------
/android/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
10 | DEFAULT_JVM_OPTS=""
11 |
12 | APP_NAME="Gradle"
13 | APP_BASE_NAME=`basename "$0"`
14 |
15 | # Use the maximum available, or set MAX_FD != -1 to use that value.
16 | MAX_FD="maximum"
17 |
18 | warn ( ) {
19 | echo "$*"
20 | }
21 |
22 | die ( ) {
23 | echo
24 | echo "$*"
25 | echo
26 | exit 1
27 | }
28 |
29 | # OS specific support (must be 'true' or 'false').
30 | cygwin=false
31 | msys=false
32 | darwin=false
33 | case "`uname`" in
34 | CYGWIN* )
35 | cygwin=true
36 | ;;
37 | Darwin* )
38 | darwin=true
39 | ;;
40 | MINGW* )
41 | msys=true
42 | ;;
43 | esac
44 |
45 | # Attempt to set APP_HOME
46 | # Resolve links: $0 may be a link
47 | PRG="$0"
48 | # Need this for relative symlinks.
49 | while [ -h "$PRG" ] ; do
50 | ls=`ls -ld "$PRG"`
51 | link=`expr "$ls" : '.*-> \(.*\)$'`
52 | if expr "$link" : '/.*' > /dev/null; then
53 | PRG="$link"
54 | else
55 | PRG=`dirname "$PRG"`"/$link"
56 | fi
57 | done
58 | SAVED="`pwd`"
59 | cd "`dirname \"$PRG\"`/" >/dev/null
60 | APP_HOME="`pwd -P`"
61 | cd "$SAVED" >/dev/null
62 |
63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
64 |
65 | # Determine the Java command to use to start the JVM.
66 | if [ -n "$JAVA_HOME" ] ; then
67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
68 | # IBM's JDK on AIX uses strange locations for the executables
69 | JAVACMD="$JAVA_HOME/jre/sh/java"
70 | else
71 | JAVACMD="$JAVA_HOME/bin/java"
72 | fi
73 | if [ ! -x "$JAVACMD" ] ; then
74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
75 |
76 | Please set the JAVA_HOME variable in your environment to match the
77 | location of your Java installation."
78 | fi
79 | else
80 | JAVACMD="java"
81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
82 |
83 | Please set the JAVA_HOME variable in your environment to match the
84 | location of your Java installation."
85 | fi
86 |
87 | # Increase the maximum file descriptors if we can.
88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
89 | MAX_FD_LIMIT=`ulimit -H -n`
90 | if [ $? -eq 0 ] ; then
91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
92 | MAX_FD="$MAX_FD_LIMIT"
93 | fi
94 | ulimit -n $MAX_FD
95 | if [ $? -ne 0 ] ; then
96 | warn "Could not set maximum file descriptor limit: $MAX_FD"
97 | fi
98 | else
99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
100 | fi
101 | fi
102 |
103 | # For Darwin, add options to specify how the application appears in the dock
104 | if $darwin; then
105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
106 | fi
107 |
108 | # For Cygwin, switch paths to Windows format before running java
109 | if $cygwin ; then
110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
112 | JAVACMD=`cygpath --unix "$JAVACMD"`
113 |
114 | # We build the pattern for arguments to be converted via cygpath
115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
116 | SEP=""
117 | for dir in $ROOTDIRSRAW ; do
118 | ROOTDIRS="$ROOTDIRS$SEP$dir"
119 | SEP="|"
120 | done
121 | OURCYGPATTERN="(^($ROOTDIRS))"
122 | # Add a user-defined pattern to the cygpath arguments
123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
125 | fi
126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
127 | i=0
128 | for arg in "$@" ; do
129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
131 |
132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
134 | else
135 | eval `echo args$i`="\"$arg\""
136 | fi
137 | i=$((i+1))
138 | done
139 | case $i in
140 | (0) set -- ;;
141 | (1) set -- "$args0" ;;
142 | (2) set -- "$args0" "$args1" ;;
143 | (3) set -- "$args0" "$args1" "$args2" ;;
144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
150 | esac
151 | fi
152 |
153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
154 | function splitJvmOpts() {
155 | JVM_OPTS=("$@")
156 | }
157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
159 |
160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
161 |
--------------------------------------------------------------------------------
/android/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
12 | set DEFAULT_JVM_OPTS=
13 |
14 | set DIRNAME=%~dp0
15 | if "%DIRNAME%" == "" set DIRNAME=.
16 | set APP_BASE_NAME=%~n0
17 | set APP_HOME=%DIRNAME%
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windowz variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 | if "%@eval[2+2]" == "4" goto 4NT_args
53 |
54 | :win9xME_args
55 | @rem Slurp the command line arguments.
56 | set CMD_LINE_ARGS=
57 | set _SKIP=2
58 |
59 | :win9xME_args_slurp
60 | if "x%~1" == "x" goto execute
61 |
62 | set CMD_LINE_ARGS=%*
63 | goto execute
64 |
65 | :4NT_args
66 | @rem Get arguments from the 4NT Shell from JP Software
67 | set CMD_LINE_ARGS=%$
68 |
69 | :execute
70 | @rem Setup the command line
71 |
72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
73 |
74 | @rem Execute Gradle
75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
76 |
77 | :end
78 | @rem End local scope for the variables with windows NT shell
79 | if "%ERRORLEVEL%"=="0" goto mainEnd
80 |
81 | :fail
82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83 | rem the _cmd.exe /c_ return code!
84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
85 | exit /b 1
86 |
87 | :mainEnd
88 | if "%OS%"=="Windows_NT" endlocal
89 |
90 | :omega
91 |
--------------------------------------------------------------------------------
/android/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app'
2 |
--------------------------------------------------------------------------------
/laravel/.env.example:
--------------------------------------------------------------------------------
1 | APP_NAME=Laravel
2 | APP_ENV=local
3 | APP_KEY=
4 | APP_DEBUG=true
5 | APP_LOG_LEVEL=debug
6 | APP_URL=http://localhost
7 |
8 | DB_CONNECTION=mysql
9 | DB_HOST=127.0.0.1
10 | DB_PORT=3306
11 | DB_DATABASE=homestead
12 | DB_USERNAME=homestead
13 | DB_PASSWORD=secret
14 |
15 | BROADCAST_DRIVER=log
16 | CACHE_DRIVER=file
17 | SESSION_DRIVER=file
18 | QUEUE_DRIVER=sync
19 |
20 | REDIS_HOST=127.0.0.1
21 | REDIS_PASSWORD=null
22 | REDIS_PORT=6379
23 |
24 | MAIL_DRIVER=smtp
25 | MAIL_HOST=smtp.mailtrap.io
26 | MAIL_PORT=2525
27 | MAIL_USERNAME=null
28 | MAIL_PASSWORD=null
29 | MAIL_ENCRYPTION=null
30 |
31 | PUSHER_APP_ID=
32 | PUSHER_APP_KEY=
33 | PUSHER_APP_SECRET=
34 |
--------------------------------------------------------------------------------
/laravel/.gitattributes:
--------------------------------------------------------------------------------
1 | * text=auto
2 | *.css linguist-vendored
3 | *.scss linguist-vendored
4 | *.js linguist-vendored
5 | CHANGELOG.md export-ignore
6 |
--------------------------------------------------------------------------------
/laravel/.gitignore:
--------------------------------------------------------------------------------
1 | /node_modules
2 | /public/hot
3 | /public/storage
4 | /storage/*.key
5 | /vendor
6 | /.idea
7 | /.vagrant
8 | Homestead.json
9 | Homestead.yaml
10 | npm-debug.log
11 | .env
12 |
--------------------------------------------------------------------------------
/laravel/app/Console/Kernel.php:
--------------------------------------------------------------------------------
1 | command('inspire')
28 | // ->hourly();
29 | }
30 |
31 | /**
32 | * Register the Closure based commands for the application.
33 | *
34 | * @return void
35 | */
36 | protected function commands()
37 | {
38 | require base_path('routes/console.php');
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/laravel/app/Exceptions/Handler.php:
--------------------------------------------------------------------------------
1 | expectsJson()) {
61 | return response()->json(['error' => 'Unauthenticated.'], 401);
62 | }
63 |
64 | return redirect()->guest(route('login'));
65 | }
66 | }
67 |
--------------------------------------------------------------------------------
/laravel/app/Http/Controllers/Api/Auth/IssueTokenTrait.php:
--------------------------------------------------------------------------------
1 | $grantType,
14 | 'client_id' => $this->client->id,
15 | 'client_secret' => $this->client->secret,
16 | 'scope' => $scope
17 | ];
18 |
19 | if($grantType !== 'social'){
20 | $params['username'] = $request->username ?: $request->email;
21 | }
22 |
23 | $request->request->add($params);
24 |
25 | $proxy = Request::create('oauth/token', 'POST');
26 |
27 | return Route::dispatch($proxy);
28 |
29 | }
30 |
31 | }
--------------------------------------------------------------------------------
/laravel/app/Http/Controllers/Api/Auth/LoginController.php:
--------------------------------------------------------------------------------
1 | client = Client::find(1);
21 | }
22 |
23 | public function login(Request $request){
24 |
25 | $this->validate($request, [
26 | 'username' => 'required',
27 | 'password' => 'required'
28 | ]);
29 |
30 | return $this->issueToken($request, 'password');
31 |
32 | }
33 |
34 | public function refresh(Request $request){
35 | $this->validate($request, [
36 | 'refresh_token' => 'required'
37 | ]);
38 |
39 | return $this->issueToken($request, 'refresh_token');
40 |
41 | }
42 |
43 | public function logout(Request $request){
44 |
45 | $accessToken = Auth::user()->token();
46 |
47 | DB::table('oauth_refresh_tokens')
48 | ->where('access_token_id', $accessToken->id)
49 | ->update(['revoked' => true]);
50 |
51 | $accessToken->revoke();
52 |
53 | return response()->json([], 204);
54 |
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/laravel/app/Http/Controllers/Api/Auth/RegisterController.php:
--------------------------------------------------------------------------------
1 | client = Client::find(1);
19 | }
20 |
21 | public function register(Request $request){
22 |
23 | $this->validate($request, [
24 | 'name' => 'required',
25 | 'email' => 'required|email|unique:users,email',
26 | 'password' => 'required|min:6'
27 | ]);
28 |
29 | $user = User::create([
30 | 'name' => request('name'),
31 | 'email' => request('email'),
32 | 'password' => bcrypt(request('password'))
33 | ]);
34 |
35 | return $this->issueToken($request, 'password');
36 |
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/laravel/app/Http/Controllers/Api/Auth/SocialAuthController.php:
--------------------------------------------------------------------------------
1 | client = Client::find(1);
23 | }
24 |
25 | public function socialAuth(Request $request){
26 |
27 | $this->validate($request, [
28 | 'name' => 'required',
29 | 'email' => 'nullable|email',
30 | 'provider' => 'required|in:facebook,twitter,google',
31 | 'provider_user_id' => 'required'
32 | ]);
33 |
34 | $socialAccount = SocialAccount::where('provider', $request->provider)->where('provider_user_id', $request->provider_user_id)->first();
35 |
36 | if($socialAccount){
37 | return $this->issueToken($request, 'social');
38 | }
39 |
40 | //Since we can have nullable email, we need to make sure that user email is not null ;)
41 | //Thx to hdahon for the fix
42 | $user = User::where('email', $request->email)
43 | ->whereNotNull("email")
44 | ->first();
45 |
46 | if($user){
47 | $this->addSocialAccountToUser($request, $user);
48 | }else{
49 | try{
50 | $this->createUserAccount($request);
51 | }catch(\Exception $e){
52 | return response("An Error Occured, please retry later", 422);
53 | }
54 | }
55 |
56 | return $this->issueToken($request, 'social');
57 | }
58 |
59 | /**
60 | * Associate social account to user
61 | * @param Request $request [description]
62 | * @param User $user [description]
63 | */
64 | private function addSocialAccountToUser(Request $request, User $user){
65 |
66 | $this->validate($request, [
67 | 'provider' => ['required', Rule::unique('social_accounts')->where(function($query) use ($user) {
68 | return $query->where('user_id', $user->id);
69 | })],
70 | 'provider_user_id' => 'required'
71 | ]);
72 |
73 | $user->socialAccounts()->create([
74 | 'provider' => $request->provider,
75 | 'provider_user_id' => $request->provider_user_id
76 | ]);
77 |
78 | }
79 |
80 | /**
81 | * Create user accound and Social account
82 | * @param Request $request [description]
83 | * @return [type] [description]
84 | */
85 | private function createUserAccount(Request $request){
86 |
87 | DB::transaction( function () use ($request){
88 |
89 | $user = User::create([
90 | 'name' => $request->name,
91 | 'email' => $request->email
92 | ]);
93 |
94 | $this->addSocialAccountToUser($request, $user);
95 |
96 | });
97 |
98 | }
99 | }
100 |
--------------------------------------------------------------------------------
/laravel/app/Http/Controllers/Api/PostController.php:
--------------------------------------------------------------------------------
1 | posts()->get();
14 |
15 | return response()->json(['data' => $posts], 200, [], JSON_NUMERIC_CHECK);
16 |
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/laravel/app/Http/Controllers/Auth/ForgotPasswordController.php:
--------------------------------------------------------------------------------
1 | middleware('guest');
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/laravel/app/Http/Controllers/Auth/LoginController.php:
--------------------------------------------------------------------------------
1 | middleware('guest')->except('logout');
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/laravel/app/Http/Controllers/Auth/RegisterController.php:
--------------------------------------------------------------------------------
1 | middleware('guest');
40 | }
41 |
42 | /**
43 | * Get a validator for an incoming registration request.
44 | *
45 | * @param array $data
46 | * @return \Illuminate\Contracts\Validation\Validator
47 | */
48 | protected function validator(array $data)
49 | {
50 | return Validator::make($data, [
51 | 'name' => 'required|string|max:255',
52 | 'email' => 'required|string|email|max:255|unique:users',
53 | 'password' => 'required|string|min:6|confirmed',
54 | ]);
55 | }
56 |
57 | /**
58 | * Create a new user instance after a valid registration.
59 | *
60 | * @param array $data
61 | * @return User
62 | */
63 | protected function create(array $data)
64 | {
65 | return User::create([
66 | 'name' => $data['name'],
67 | 'email' => $data['email'],
68 | 'password' => bcrypt($data['password']),
69 | ]);
70 | }
71 | }
72 |
--------------------------------------------------------------------------------
/laravel/app/Http/Controllers/Auth/ResetPasswordController.php:
--------------------------------------------------------------------------------
1 | middleware('guest');
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/laravel/app/Http/Controllers/Controller.php:
--------------------------------------------------------------------------------
1 | setUserRepository($userRepository);
29 | $this->setRefreshTokenRepository($refreshTokenRepository);
30 |
31 | $this->refreshTokenTTL = new \DateInterval('P1M');
32 | }
33 |
34 | /**
35 | * {@inheritdoc}
36 | */
37 | public function respondToAccessTokenRequest(
38 | ServerRequestInterface $request,
39 | ResponseTypeInterface $responseType,
40 | \DateInterval $accessTokenTTL
41 | ) {
42 | // Validate request
43 | $client = $this->validateClient($request);
44 | $scopes = $this->validateScopes($this->getRequestParameter('scope', $request));
45 | $user = $this->validateUser($request, $client);
46 |
47 | // Finalize the requested scopes
48 | $scopes = $this->scopeRepository->finalizeScopes($scopes, $this->getIdentifier(), $client, $user->getIdentifier());
49 |
50 | // Issue and persist new tokens
51 | $accessToken = $this->issueAccessToken($accessTokenTTL, $client, $user->getIdentifier(), $scopes);
52 | $refreshToken = $this->issueRefreshToken($accessToken);
53 |
54 | // Inject tokens into response
55 | $responseType->setAccessToken($accessToken);
56 | $responseType->setRefreshToken($refreshToken);
57 |
58 | return $responseType;
59 | }
60 |
61 | /**
62 | * @param ServerRequestInterface $request
63 | * @param ClientEntityInterface $client
64 | *
65 | * @throws OAuthServerException
66 | *
67 | * @return UserEntityInterface
68 | */
69 | protected function validateUser(ServerRequestInterface $request, ClientEntityInterface $client)
70 | {
71 | $provider = $this->getRequestParameter('provider', $request);
72 | if (is_null($provider)) {
73 | throw OAuthServerException::invalidRequest('provider');
74 | }
75 |
76 | $provider_user_id = $this->getRequestParameter('provider_user_id', $request);
77 | if (is_null($provider_user_id)) {
78 | throw OAuthServerException::invalidRequest('provider_user_id');
79 | }
80 |
81 | $user = $this->getUserFromSocialNetwork(new Request($request->getParsedBody()));
82 |
83 | if ($user instanceof UserEntityInterface === false) {
84 | $this->getEmitter()->emit(new RequestEvent(RequestEvent::USER_AUTHENTICATION_FAILED, $request));
85 |
86 | throw OAuthServerException::invalidCredentials();
87 | }
88 |
89 | return $user;
90 | }
91 |
92 | private function getUserFromSocialNetwork(Request $request){
93 |
94 | $provider = config('auth.guards.api.provider');
95 |
96 | if (is_null($model = config('auth.providers.'.$provider.'.model'))) {
97 | throw new RuntimeException('Unable to determine authentication model from configuration.');
98 | }
99 |
100 | $socialAccount = SocialAccount::where('provider', $request->provider)->where('provider_user_id', $request->provider_user_id)->first();
101 |
102 | if(!$socialAccount) return;
103 |
104 | $user = $socialAccount->user()->first();
105 |
106 | if(!$user) return;
107 |
108 | return new User($user->getAuthIdentifier());
109 |
110 | }
111 |
112 | /**
113 | * {@inheritdoc}
114 | */
115 | public function getIdentifier()
116 | {
117 | return 'social';
118 | }
119 |
120 | }
--------------------------------------------------------------------------------
/laravel/app/Http/Kernel.php:
--------------------------------------------------------------------------------
1 | [
30 | \App\Http\Middleware\EncryptCookies::class,
31 | \Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
32 | \Illuminate\Session\Middleware\StartSession::class,
33 | // \Illuminate\Session\Middleware\AuthenticateSession::class,
34 | \Illuminate\View\Middleware\ShareErrorsFromSession::class,
35 | \App\Http\Middleware\VerifyCsrfToken::class,
36 | \Illuminate\Routing\Middleware\SubstituteBindings::class,
37 | ],
38 |
39 | 'api' => [
40 | 'throttle:60,1',
41 | 'bindings',
42 | ],
43 | ];
44 |
45 | /**
46 | * The application's route middleware.
47 | *
48 | * These middleware may be assigned to groups or used individually.
49 | *
50 | * @var array
51 | */
52 | protected $routeMiddleware = [
53 | 'auth' => \Illuminate\Auth\Middleware\Authenticate::class,
54 | 'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
55 | 'bindings' => \Illuminate\Routing\Middleware\SubstituteBindings::class,
56 | 'can' => \Illuminate\Auth\Middleware\Authorize::class,
57 | 'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class,
58 | 'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
59 | ];
60 | }
61 |
--------------------------------------------------------------------------------
/laravel/app/Http/Middleware/EncryptCookies.php:
--------------------------------------------------------------------------------
1 | check()) {
21 | return redirect('/home');
22 | }
23 |
24 | return $next($request);
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/laravel/app/Http/Middleware/TrimStrings.php:
--------------------------------------------------------------------------------
1 | belongsTo(User::class);
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/laravel/app/Providers/AppServiceProvider.php:
--------------------------------------------------------------------------------
1 | 'App\Policies\ModelPolicy',
19 | ];
20 |
21 | /**
22 | * Register any authentication / authorization services.
23 | *
24 | * @return void
25 | */
26 | public function boot()
27 | {
28 | $this->registerPolicies();
29 |
30 | Passport::routes();
31 |
32 | Passport::tokensExpireIn(Carbon::now()->addMinutes(1));
33 |
34 | Passport::refreshTokensExpireIn(Carbon::now()->addDays(30));
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/laravel/app/Providers/BroadcastServiceProvider.php:
--------------------------------------------------------------------------------
1 | [
17 | 'App\Listeners\EventListener',
18 | ],
19 | ];
20 |
21 | /**
22 | * Register any events for your application.
23 | *
24 | * @return void
25 | */
26 | public function boot()
27 | {
28 | parent::boot();
29 |
30 | //
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/laravel/app/Providers/RouteServiceProvider.php:
--------------------------------------------------------------------------------
1 | mapApiRoutes();
39 |
40 | $this->mapWebRoutes();
41 |
42 | //
43 | }
44 |
45 | /**
46 | * Define the "web" routes for the application.
47 | *
48 | * These routes all receive session state, CSRF protection, etc.
49 | *
50 | * @return void
51 | */
52 | protected function mapWebRoutes()
53 | {
54 | Route::middleware('web')
55 | ->namespace($this->namespace)
56 | ->group(base_path('routes/web.php'));
57 | }
58 |
59 | /**
60 | * Define the "api" routes for the application.
61 | *
62 | * These routes are typically stateless.
63 | *
64 | * @return void
65 | */
66 | protected function mapApiRoutes()
67 | {
68 | Route::prefix('api')
69 | ->middleware('api')
70 | ->namespace($this->namespace)
71 | ->group(base_path('routes/api.php'));
72 | }
73 | }
74 |
--------------------------------------------------------------------------------
/laravel/app/Providers/SocialAuthServiceProvider.php:
--------------------------------------------------------------------------------
1 | afterResolving(AuthorizationServer::class, function (AuthorizationServer $server) {
32 | $grant = $this->makeGrant();
33 | $server->enableGrantType($grant, Passport::tokensExpireIn());
34 | });
35 | }
36 |
37 |
38 | private function makeGrant(){
39 | $grant = new SocialGrant(
40 | $this->app->make(UserRepository::class),
41 | $this->app->make(RefreshTokenRepository::class)
42 | );
43 |
44 | $grant->setRefreshTokenTTL(Passport::refreshTokensExpireIn());
45 |
46 | return $grant;
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/laravel/app/SocialAccount.php:
--------------------------------------------------------------------------------
1 | belongsTo(User::class);
15 | }
16 |
17 | }
18 |
--------------------------------------------------------------------------------
/laravel/app/User.php:
--------------------------------------------------------------------------------
1 | hasMany(SocialAccount::class);
35 | }
36 |
37 | public function posts(){
38 | return $this->hasMany(Post::class);
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/laravel/artisan:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env php
2 | make(Illuminate\Contracts\Console\Kernel::class);
32 |
33 | $status = $kernel->handle(
34 | $input = new Symfony\Component\Console\Input\ArgvInput,
35 | new Symfony\Component\Console\Output\ConsoleOutput
36 | );
37 |
38 | /*
39 | |--------------------------------------------------------------------------
40 | | Shutdown The Application
41 | |--------------------------------------------------------------------------
42 | |
43 | | Once Artisan has finished running, we will fire off the shutdown events
44 | | so that any final work may be done by the application before we shut
45 | | down the process. This is the last thing to happen to the request.
46 | |
47 | */
48 |
49 | $kernel->terminate($input, $status);
50 |
51 | exit($status);
52 |
--------------------------------------------------------------------------------
/laravel/bootstrap/app.php:
--------------------------------------------------------------------------------
1 | singleton(
30 | Illuminate\Contracts\Http\Kernel::class,
31 | App\Http\Kernel::class
32 | );
33 |
34 | $app->singleton(
35 | Illuminate\Contracts\Console\Kernel::class,
36 | App\Console\Kernel::class
37 | );
38 |
39 | $app->singleton(
40 | Illuminate\Contracts\Debug\ExceptionHandler::class,
41 | App\Exceptions\Handler::class
42 | );
43 |
44 | /*
45 | |--------------------------------------------------------------------------
46 | | Return The Application
47 | |--------------------------------------------------------------------------
48 | |
49 | | This script returns the application instance. The instance is given to
50 | | the calling script so we can separate the building of the instances
51 | | from the actual running of the application and sending responses.
52 | |
53 | */
54 |
55 | return $app;
56 |
--------------------------------------------------------------------------------
/laravel/bootstrap/autoload.php:
--------------------------------------------------------------------------------
1 | =5.6.4",
9 | "laravel/framework": "5.5.*",
10 | "laravel/passport": "^4.0",
11 | "laravel/tinker": "~1.0"
12 | },
13 | "require-dev": {
14 | "fzaninotto/faker": "~1.4",
15 | "mockery/mockery": "0.9.*",
16 | "phpunit/phpunit": "~6.0",
17 | "filp/whoops": "~2.0"
18 | },
19 | "autoload": {
20 | "classmap": [
21 | "database"
22 | ],
23 | "psr-4": {
24 | "App\\": "app/"
25 | }
26 | },
27 | "autoload-dev": {
28 | "psr-4": {
29 | "Tests\\": "tests/"
30 | }
31 | },
32 | "scripts": {
33 | "post-root-package-install": [
34 | "php -r \"file_exists('.env') || copy('.env.example', '.env');\""
35 | ],
36 | "post-create-project-cmd": [
37 | "php artisan key:generate"
38 | ],
39 | "post-install-cmd": [
40 | "Illuminate\\Foundation\\ComposerScripts::postInstall",
41 | "php artisan optimize"
42 | ],
43 | "post-update-cmd": [
44 | "Illuminate\\Foundation\\ComposerScripts::postUpdate",
45 | "php artisan optimize"
46 | ],
47 | "post-autoload-dump": [
48 | "Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",
49 | "@php artisan package:discover"
50 | ]
51 | },
52 | "config": {
53 | "preferred-install": "dist",
54 | "sort-packages": true,
55 | "optimize-autoloader": true
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/laravel/config/app.php:
--------------------------------------------------------------------------------
1 | env('APP_NAME', 'Laravel'),
16 |
17 | /*
18 | |--------------------------------------------------------------------------
19 | | Application Environment
20 | |--------------------------------------------------------------------------
21 | |
22 | | This value determines the "environment" your application is currently
23 | | running in. This may determine how you prefer to configure various
24 | | services your application utilizes. Set this in your ".env" file.
25 | |
26 | */
27 |
28 | 'env' => env('APP_ENV', 'production'),
29 |
30 | /*
31 | |--------------------------------------------------------------------------
32 | | Application Debug Mode
33 | |--------------------------------------------------------------------------
34 | |
35 | | When your application is in debug mode, detailed error messages with
36 | | stack traces will be shown on every error that occurs within your
37 | | application. If disabled, a simple generic error page is shown.
38 | |
39 | */
40 |
41 | 'debug' => env('APP_DEBUG', false),
42 |
43 | /*
44 | |--------------------------------------------------------------------------
45 | | Application URL
46 | |--------------------------------------------------------------------------
47 | |
48 | | This URL is used by the console to properly generate URLs when using
49 | | the Artisan command line tool. You should set this to the root of
50 | | your application so that it is used when running Artisan tasks.
51 | |
52 | */
53 |
54 | 'url' => env('APP_URL', 'http://localhost'),
55 |
56 | /*
57 | |--------------------------------------------------------------------------
58 | | Application Timezone
59 | |--------------------------------------------------------------------------
60 | |
61 | | Here you may specify the default timezone for your application, which
62 | | will be used by the PHP date and date-time functions. We have gone
63 | | ahead and set this to a sensible default for you out of the box.
64 | |
65 | */
66 |
67 | 'timezone' => 'UTC',
68 |
69 | /*
70 | |--------------------------------------------------------------------------
71 | | Application Locale Configuration
72 | |--------------------------------------------------------------------------
73 | |
74 | | The application locale determines the default locale that will be used
75 | | by the translation service provider. You are free to set this value
76 | | to any of the locales which will be supported by the application.
77 | |
78 | */
79 |
80 | 'locale' => 'en',
81 |
82 | /*
83 | |--------------------------------------------------------------------------
84 | | Application Fallback Locale
85 | |--------------------------------------------------------------------------
86 | |
87 | | The fallback locale determines the locale to use when the current one
88 | | is not available. You may change the value to correspond to any of
89 | | the language folders that are provided through your application.
90 | |
91 | */
92 |
93 | 'fallback_locale' => 'en',
94 |
95 | /*
96 | |--------------------------------------------------------------------------
97 | | Encryption Key
98 | |--------------------------------------------------------------------------
99 | |
100 | | This key is used by the Illuminate encrypter service and should be set
101 | | to a random, 32 character string, otherwise these encrypted strings
102 | | will not be safe. Please do this before deploying an application!
103 | |
104 | */
105 |
106 | 'key' => env('APP_KEY'),
107 |
108 | 'cipher' => 'AES-256-CBC',
109 |
110 | /*
111 | |--------------------------------------------------------------------------
112 | | Logging Configuration
113 | |--------------------------------------------------------------------------
114 | |
115 | | Here you may configure the log settings for your application. Out of
116 | | the box, Laravel uses the Monolog PHP logging library. This gives
117 | | you a variety of powerful log handlers / formatters to utilize.
118 | |
119 | | Available Settings: "single", "daily", "syslog", "errorlog"
120 | |
121 | */
122 |
123 | 'log' => env('APP_LOG', 'single'),
124 |
125 | 'log_level' => env('APP_LOG_LEVEL', 'debug'),
126 |
127 | /*
128 | |--------------------------------------------------------------------------
129 | | Autoloaded Service Providers
130 | |--------------------------------------------------------------------------
131 | |
132 | | The service providers listed here will be automatically loaded on the
133 | | request to your application. Feel free to add your own services to
134 | | this array to grant expanded functionality to your applications.
135 | |
136 | */
137 |
138 | 'providers' => [
139 |
140 | /*
141 | * Laravel Framework Service Providers...
142 | */
143 | Illuminate\Auth\AuthServiceProvider::class,
144 | Illuminate\Broadcasting\BroadcastServiceProvider::class,
145 | Illuminate\Bus\BusServiceProvider::class,
146 | Illuminate\Cache\CacheServiceProvider::class,
147 | Illuminate\Foundation\Providers\ConsoleSupportServiceProvider::class,
148 | Illuminate\Cookie\CookieServiceProvider::class,
149 | Illuminate\Database\DatabaseServiceProvider::class,
150 | Illuminate\Encryption\EncryptionServiceProvider::class,
151 | Illuminate\Filesystem\FilesystemServiceProvider::class,
152 | Illuminate\Foundation\Providers\FoundationServiceProvider::class,
153 | Illuminate\Hashing\HashServiceProvider::class,
154 | Illuminate\Mail\MailServiceProvider::class,
155 | Illuminate\Notifications\NotificationServiceProvider::class,
156 | Illuminate\Pagination\PaginationServiceProvider::class,
157 | Illuminate\Pipeline\PipelineServiceProvider::class,
158 | Illuminate\Queue\QueueServiceProvider::class,
159 | Illuminate\Redis\RedisServiceProvider::class,
160 | Illuminate\Auth\Passwords\PasswordResetServiceProvider::class,
161 | Illuminate\Session\SessionServiceProvider::class,
162 | Illuminate\Translation\TranslationServiceProvider::class,
163 | Illuminate\Validation\ValidationServiceProvider::class,
164 | Illuminate\View\ViewServiceProvider::class,
165 |
166 | /*
167 | * Package Service Providers...
168 | */
169 | Laravel\Tinker\TinkerServiceProvider::class,
170 | Laravel\Passport\PassportServiceProvider::class,
171 |
172 | /*
173 | * Application Service Providers...
174 | */
175 | App\Providers\AppServiceProvider::class,
176 | App\Providers\AuthServiceProvider::class,
177 | // App\Providers\BroadcastServiceProvider::class,
178 | App\Providers\EventServiceProvider::class,
179 | App\Providers\RouteServiceProvider::class,
180 | App\Providers\SocialAuthServiceProvider::class
181 |
182 | ],
183 |
184 | /*
185 | |--------------------------------------------------------------------------
186 | | Class Aliases
187 | |--------------------------------------------------------------------------
188 | |
189 | | This array of class aliases will be registered when this application
190 | | is started. However, feel free to register as many as you wish as
191 | | the aliases are "lazy" loaded so they don't hinder performance.
192 | |
193 | */
194 |
195 | 'aliases' => [
196 |
197 | 'App' => Illuminate\Support\Facades\App::class,
198 | 'Artisan' => Illuminate\Support\Facades\Artisan::class,
199 | 'Auth' => Illuminate\Support\Facades\Auth::class,
200 | 'Blade' => Illuminate\Support\Facades\Blade::class,
201 | 'Broadcast' => Illuminate\Support\Facades\Broadcast::class,
202 | 'Bus' => Illuminate\Support\Facades\Bus::class,
203 | 'Cache' => Illuminate\Support\Facades\Cache::class,
204 | 'Config' => Illuminate\Support\Facades\Config::class,
205 | 'Cookie' => Illuminate\Support\Facades\Cookie::class,
206 | 'Crypt' => Illuminate\Support\Facades\Crypt::class,
207 | 'DB' => Illuminate\Support\Facades\DB::class,
208 | 'Eloquent' => Illuminate\Database\Eloquent\Model::class,
209 | 'Event' => Illuminate\Support\Facades\Event::class,
210 | 'File' => Illuminate\Support\Facades\File::class,
211 | 'Gate' => Illuminate\Support\Facades\Gate::class,
212 | 'Hash' => Illuminate\Support\Facades\Hash::class,
213 | 'Lang' => Illuminate\Support\Facades\Lang::class,
214 | 'Log' => Illuminate\Support\Facades\Log::class,
215 | 'Mail' => Illuminate\Support\Facades\Mail::class,
216 | 'Notification' => Illuminate\Support\Facades\Notification::class,
217 | 'Password' => Illuminate\Support\Facades\Password::class,
218 | 'Queue' => Illuminate\Support\Facades\Queue::class,
219 | 'Redirect' => Illuminate\Support\Facades\Redirect::class,
220 | 'Redis' => Illuminate\Support\Facades\Redis::class,
221 | 'Request' => Illuminate\Support\Facades\Request::class,
222 | 'Response' => Illuminate\Support\Facades\Response::class,
223 | 'Route' => Illuminate\Support\Facades\Route::class,
224 | 'Schema' => Illuminate\Support\Facades\Schema::class,
225 | 'Session' => Illuminate\Support\Facades\Session::class,
226 | 'Storage' => Illuminate\Support\Facades\Storage::class,
227 | 'URL' => Illuminate\Support\Facades\URL::class,
228 | 'Validator' => Illuminate\Support\Facades\Validator::class,
229 | 'View' => Illuminate\Support\Facades\View::class,
230 |
231 | ],
232 |
233 | ];
234 |
--------------------------------------------------------------------------------
/laravel/config/auth.php:
--------------------------------------------------------------------------------
1 | [
17 | 'guard' => 'web',
18 | 'passwords' => 'users',
19 | ],
20 |
21 | /*
22 | |--------------------------------------------------------------------------
23 | | Authentication Guards
24 | |--------------------------------------------------------------------------
25 | |
26 | | Next, you may define every authentication guard for your application.
27 | | Of course, a great default configuration has been defined for you
28 | | here which uses session storage and the Eloquent user provider.
29 | |
30 | | All authentication drivers have a user provider. This defines how the
31 | | users are actually retrieved out of your database or other storage
32 | | mechanisms used by this application to persist your user's data.
33 | |
34 | | Supported: "session", "token"
35 | |
36 | */
37 |
38 | 'guards' => [
39 | 'web' => [
40 | 'driver' => 'session',
41 | 'provider' => 'users',
42 | ],
43 |
44 | 'api' => [
45 | 'driver' => 'passport',
46 | 'provider' => 'users',
47 | ],
48 | ],
49 |
50 | /*
51 | |--------------------------------------------------------------------------
52 | | User Providers
53 | |--------------------------------------------------------------------------
54 | |
55 | | All authentication drivers have a user provider. This defines how the
56 | | users are actually retrieved out of your database or other storage
57 | | mechanisms used by this application to persist your user's data.
58 | |
59 | | If you have multiple user tables or models you may configure multiple
60 | | sources which represent each model / table. These sources may then
61 | | be assigned to any extra authentication guards you have defined.
62 | |
63 | | Supported: "database", "eloquent"
64 | |
65 | */
66 |
67 | 'providers' => [
68 | 'users' => [
69 | 'driver' => 'eloquent',
70 | 'model' => App\User::class,
71 | ],
72 |
73 | // 'users' => [
74 | // 'driver' => 'database',
75 | // 'table' => 'users',
76 | // ],
77 | ],
78 |
79 | /*
80 | |--------------------------------------------------------------------------
81 | | Resetting Passwords
82 | |--------------------------------------------------------------------------
83 | |
84 | | You may specify multiple password reset configurations if you have more
85 | | than one user table or model in the application and you want to have
86 | | separate password reset settings based on the specific user types.
87 | |
88 | | The expire time is the number of minutes that the reset token should be
89 | | considered valid. This security feature keeps tokens short-lived so
90 | | they have less time to be guessed. You may change this as needed.
91 | |
92 | */
93 |
94 | 'passwords' => [
95 | 'users' => [
96 | 'provider' => 'users',
97 | 'table' => 'password_resets',
98 | 'expire' => 60,
99 | ],
100 | ],
101 |
102 | ];
103 |
--------------------------------------------------------------------------------
/laravel/config/broadcasting.php:
--------------------------------------------------------------------------------
1 | env('BROADCAST_DRIVER', 'null'),
19 |
20 | /*
21 | |--------------------------------------------------------------------------
22 | | Broadcast Connections
23 | |--------------------------------------------------------------------------
24 | |
25 | | Here you may define all of the broadcast connections that will be used
26 | | to broadcast events to other systems or over websockets. Samples of
27 | | each available type of connection are provided inside this array.
28 | |
29 | */
30 |
31 | 'connections' => [
32 |
33 | 'pusher' => [
34 | 'driver' => 'pusher',
35 | 'key' => env('PUSHER_APP_KEY'),
36 | 'secret' => env('PUSHER_APP_SECRET'),
37 | 'app_id' => env('PUSHER_APP_ID'),
38 | 'options' => [
39 | //
40 | ],
41 | ],
42 |
43 | 'redis' => [
44 | 'driver' => 'redis',
45 | 'connection' => 'default',
46 | ],
47 |
48 | 'log' => [
49 | 'driver' => 'log',
50 | ],
51 |
52 | 'null' => [
53 | 'driver' => 'null',
54 | ],
55 |
56 | ],
57 |
58 | ];
59 |
--------------------------------------------------------------------------------
/laravel/config/cache.php:
--------------------------------------------------------------------------------
1 | env('CACHE_DRIVER', 'file'),
19 |
20 | /*
21 | |--------------------------------------------------------------------------
22 | | Cache Stores
23 | |--------------------------------------------------------------------------
24 | |
25 | | Here you may define all of the cache "stores" for your application as
26 | | well as their drivers. You may even define multiple stores for the
27 | | same cache driver to group types of items stored in your caches.
28 | |
29 | */
30 |
31 | 'stores' => [
32 |
33 | 'apc' => [
34 | 'driver' => 'apc',
35 | ],
36 |
37 | 'array' => [
38 | 'driver' => 'array',
39 | ],
40 |
41 | 'database' => [
42 | 'driver' => 'database',
43 | 'table' => 'cache',
44 | 'connection' => null,
45 | ],
46 |
47 | 'file' => [
48 | 'driver' => 'file',
49 | 'path' => storage_path('framework/cache/data'),
50 | ],
51 |
52 | 'memcached' => [
53 | 'driver' => 'memcached',
54 | 'persistent_id' => env('MEMCACHED_PERSISTENT_ID'),
55 | 'sasl' => [
56 | env('MEMCACHED_USERNAME'),
57 | env('MEMCACHED_PASSWORD'),
58 | ],
59 | 'options' => [
60 | // Memcached::OPT_CONNECT_TIMEOUT => 2000,
61 | ],
62 | 'servers' => [
63 | [
64 | 'host' => env('MEMCACHED_HOST', '127.0.0.1'),
65 | 'port' => env('MEMCACHED_PORT', 11211),
66 | 'weight' => 100,
67 | ],
68 | ],
69 | ],
70 |
71 | 'redis' => [
72 | 'driver' => 'redis',
73 | 'connection' => 'default',
74 | ],
75 |
76 | ],
77 |
78 | /*
79 | |--------------------------------------------------------------------------
80 | | Cache Key Prefix
81 | |--------------------------------------------------------------------------
82 | |
83 | | When utilizing a RAM based store such as APC or Memcached, there might
84 | | be other applications utilizing the same cache. So, we'll specify a
85 | | value to get prefixed to all our keys so we can avoid collisions.
86 | |
87 | */
88 |
89 | 'prefix' => 'laravel',
90 |
91 | ];
92 |
--------------------------------------------------------------------------------
/laravel/config/database.php:
--------------------------------------------------------------------------------
1 | env('DB_CONNECTION', 'mysql'),
17 |
18 | /*
19 | |--------------------------------------------------------------------------
20 | | Database Connections
21 | |--------------------------------------------------------------------------
22 | |
23 | | Here are each of the database connections setup for your application.
24 | | Of course, examples of configuring each database platform that is
25 | | supported by Laravel is shown below to make development simple.
26 | |
27 | |
28 | | All database work in Laravel is done through the PHP PDO facilities
29 | | so make sure you have the driver for your particular database of
30 | | choice installed on your machine before you begin development.
31 | |
32 | */
33 |
34 | 'connections' => [
35 |
36 | 'sqlite' => [
37 | 'driver' => 'sqlite',
38 | 'database' => env('DB_DATABASE', database_path('database.sqlite')),
39 | 'prefix' => '',
40 | ],
41 |
42 | 'mysql' => [
43 | 'driver' => 'mysql',
44 | 'host' => env('DB_HOST', '127.0.0.1'),
45 | 'port' => env('DB_PORT', '3306'),
46 | 'database' => env('DB_DATABASE', 'forge'),
47 | 'username' => env('DB_USERNAME', 'forge'),
48 | 'password' => env('DB_PASSWORD', ''),
49 | 'unix_socket' => env('DB_SOCKET', ''),
50 | 'charset' => 'utf8mb4',
51 | 'collation' => 'utf8mb4_unicode_ci',
52 | 'prefix' => '',
53 | 'strict' => true,
54 | 'engine' => "InnoDB",
55 | ],
56 |
57 | 'pgsql' => [
58 | 'driver' => 'pgsql',
59 | 'host' => env('DB_HOST', '127.0.0.1'),
60 | 'port' => env('DB_PORT', '5432'),
61 | 'database' => env('DB_DATABASE', 'forge'),
62 | 'username' => env('DB_USERNAME', 'forge'),
63 | 'password' => env('DB_PASSWORD', ''),
64 | 'charset' => 'utf8',
65 | 'prefix' => '',
66 | 'schema' => 'public',
67 | 'sslmode' => 'prefer',
68 | ],
69 |
70 | 'sqlsrv' => [
71 | 'driver' => 'sqlsrv',
72 | 'host' => env('DB_HOST', 'localhost'),
73 | 'port' => env('DB_PORT', '1433'),
74 | 'database' => env('DB_DATABASE', 'forge'),
75 | 'username' => env('DB_USERNAME', 'forge'),
76 | 'password' => env('DB_PASSWORD', ''),
77 | 'charset' => 'utf8',
78 | 'prefix' => '',
79 | ],
80 |
81 | ],
82 |
83 | /*
84 | |--------------------------------------------------------------------------
85 | | Migration Repository Table
86 | |--------------------------------------------------------------------------
87 | |
88 | | This table keeps track of all the migrations that have already run for
89 | | your application. Using this information, we can determine which of
90 | | the migrations on disk haven't actually been run in the database.
91 | |
92 | */
93 |
94 | 'migrations' => 'migrations',
95 |
96 | /*
97 | |--------------------------------------------------------------------------
98 | | Redis Databases
99 | |--------------------------------------------------------------------------
100 | |
101 | | Redis is an open source, fast, and advanced key-value store that also
102 | | provides a richer set of commands than a typical key-value systems
103 | | such as APC or Memcached. Laravel makes it easy to dig right in.
104 | |
105 | */
106 |
107 | 'redis' => [
108 |
109 | 'client' => 'predis',
110 |
111 | 'default' => [
112 | 'host' => env('REDIS_HOST', '127.0.0.1'),
113 | 'password' => env('REDIS_PASSWORD', null),
114 | 'port' => env('REDIS_PORT', 6379),
115 | 'database' => 0,
116 | ],
117 |
118 | ],
119 |
120 | ];
121 |
--------------------------------------------------------------------------------
/laravel/config/filesystems.php:
--------------------------------------------------------------------------------
1 | env('FILESYSTEM_DRIVER', 'local'),
17 |
18 | /*
19 | |--------------------------------------------------------------------------
20 | | Default Cloud Filesystem Disk
21 | |--------------------------------------------------------------------------
22 | |
23 | | Many applications store files both locally and in the cloud. For this
24 | | reason, you may specify a default "cloud" driver here. This driver
25 | | will be bound as the Cloud disk implementation in the container.
26 | |
27 | */
28 |
29 | 'cloud' => env('FILESYSTEM_CLOUD', 's3'),
30 |
31 | /*
32 | |--------------------------------------------------------------------------
33 | | Filesystem Disks
34 | |--------------------------------------------------------------------------
35 | |
36 | | Here you may configure as many filesystem "disks" as you wish, and you
37 | | may even configure multiple disks of the same driver. Defaults have
38 | | been setup for each driver as an example of the required options.
39 | |
40 | | Supported Drivers: "local", "ftp", "s3", "rackspace"
41 | |
42 | */
43 |
44 | 'disks' => [
45 |
46 | 'local' => [
47 | 'driver' => 'local',
48 | 'root' => storage_path('app'),
49 | ],
50 |
51 | 'public' => [
52 | 'driver' => 'local',
53 | 'root' => storage_path('app/public'),
54 | 'url' => env('APP_URL').'/storage',
55 | 'visibility' => 'public',
56 | ],
57 |
58 | 's3' => [
59 | 'driver' => 's3',
60 | 'key' => env('AWS_KEY'),
61 | 'secret' => env('AWS_SECRET'),
62 | 'region' => env('AWS_REGION'),
63 | 'bucket' => env('AWS_BUCKET'),
64 | ],
65 |
66 | ],
67 |
68 | ];
69 |
--------------------------------------------------------------------------------
/laravel/config/mail.php:
--------------------------------------------------------------------------------
1 | env('MAIL_DRIVER', 'smtp'),
20 |
21 | /*
22 | |--------------------------------------------------------------------------
23 | | SMTP Host Address
24 | |--------------------------------------------------------------------------
25 | |
26 | | Here you may provide the host address of the SMTP server used by your
27 | | applications. A default option is provided that is compatible with
28 | | the Mailgun mail service which will provide reliable deliveries.
29 | |
30 | */
31 |
32 | 'host' => env('MAIL_HOST', 'smtp.mailgun.org'),
33 |
34 | /*
35 | |--------------------------------------------------------------------------
36 | | SMTP Host Port
37 | |--------------------------------------------------------------------------
38 | |
39 | | This is the SMTP port used by your application to deliver e-mails to
40 | | users of the application. Like the host we have set this value to
41 | | stay compatible with the Mailgun e-mail application by default.
42 | |
43 | */
44 |
45 | 'port' => env('MAIL_PORT', 587),
46 |
47 | /*
48 | |--------------------------------------------------------------------------
49 | | Global "From" Address
50 | |--------------------------------------------------------------------------
51 | |
52 | | You may wish for all e-mails sent by your application to be sent from
53 | | the same address. Here, you may specify a name and address that is
54 | | used globally for all e-mails that are sent by your application.
55 | |
56 | */
57 |
58 | 'from' => [
59 | 'address' => env('MAIL_FROM_ADDRESS', 'hello@example.com'),
60 | 'name' => env('MAIL_FROM_NAME', 'Example'),
61 | ],
62 |
63 | /*
64 | |--------------------------------------------------------------------------
65 | | E-Mail Encryption Protocol
66 | |--------------------------------------------------------------------------
67 | |
68 | | Here you may specify the encryption protocol that should be used when
69 | | the application send e-mail messages. A sensible default using the
70 | | transport layer security protocol should provide great security.
71 | |
72 | */
73 |
74 | 'encryption' => env('MAIL_ENCRYPTION', 'tls'),
75 |
76 | /*
77 | |--------------------------------------------------------------------------
78 | | SMTP Server Username
79 | |--------------------------------------------------------------------------
80 | |
81 | | If your SMTP server requires a username for authentication, you should
82 | | set it here. This will get used to authenticate with your server on
83 | | connection. You may also set the "password" value below this one.
84 | |
85 | */
86 |
87 | 'username' => env('MAIL_USERNAME'),
88 |
89 | 'password' => env('MAIL_PASSWORD'),
90 |
91 | /*
92 | |--------------------------------------------------------------------------
93 | | Sendmail System Path
94 | |--------------------------------------------------------------------------
95 | |
96 | | When using the "sendmail" driver to send e-mails, we will need to know
97 | | the path to where Sendmail lives on this server. A default path has
98 | | been provided here, which will work well on most of your systems.
99 | |
100 | */
101 |
102 | 'sendmail' => '/usr/sbin/sendmail -bs',
103 |
104 | /*
105 | |--------------------------------------------------------------------------
106 | | Markdown Mail Settings
107 | |--------------------------------------------------------------------------
108 | |
109 | | If you are using Markdown based email rendering, you may configure your
110 | | theme and component paths here, allowing you to customize the design
111 | | of the emails. Or, you may simply stick with the Laravel defaults!
112 | |
113 | */
114 |
115 | 'markdown' => [
116 | 'theme' => 'default',
117 |
118 | 'paths' => [
119 | resource_path('views/vendor/mail'),
120 | ],
121 | ],
122 |
123 | ];
124 |
--------------------------------------------------------------------------------
/laravel/config/queue.php:
--------------------------------------------------------------------------------
1 | env('QUEUE_DRIVER', 'sync'),
19 |
20 | /*
21 | |--------------------------------------------------------------------------
22 | | Queue Connections
23 | |--------------------------------------------------------------------------
24 | |
25 | | Here you may configure the connection information for each server that
26 | | is used by your application. A default configuration has been added
27 | | for each back-end shipped with Laravel. You are free to add more.
28 | |
29 | */
30 |
31 | 'connections' => [
32 |
33 | 'sync' => [
34 | 'driver' => 'sync',
35 | ],
36 |
37 | 'database' => [
38 | 'driver' => 'database',
39 | 'table' => 'jobs',
40 | 'queue' => 'default',
41 | 'retry_after' => 90,
42 | ],
43 |
44 | 'beanstalkd' => [
45 | 'driver' => 'beanstalkd',
46 | 'host' => 'localhost',
47 | 'queue' => 'default',
48 | 'retry_after' => 90,
49 | ],
50 |
51 | 'sqs' => [
52 | 'driver' => 'sqs',
53 | 'key' => 'your-public-key',
54 | 'secret' => 'your-secret-key',
55 | 'prefix' => 'https://sqs.us-east-1.amazonaws.com/your-account-id',
56 | 'queue' => 'your-queue-name',
57 | 'region' => 'us-east-1',
58 | ],
59 |
60 | 'redis' => [
61 | 'driver' => 'redis',
62 | 'connection' => 'default',
63 | 'queue' => 'default',
64 | 'retry_after' => 90,
65 | ],
66 |
67 | ],
68 |
69 | /*
70 | |--------------------------------------------------------------------------
71 | | Failed Queue Jobs
72 | |--------------------------------------------------------------------------
73 | |
74 | | These options configure the behavior of failed queue job logging so you
75 | | can control which database and table are used to store the jobs that
76 | | have failed. You may change them to any database / table you wish.
77 | |
78 | */
79 |
80 | 'failed' => [
81 | 'database' => env('DB_CONNECTION', 'mysql'),
82 | 'table' => 'failed_jobs',
83 | ],
84 |
85 | ];
86 |
--------------------------------------------------------------------------------
/laravel/config/services.php:
--------------------------------------------------------------------------------
1 | [
18 | 'domain' => env('MAILGUN_DOMAIN'),
19 | 'secret' => env('MAILGUN_SECRET'),
20 | ],
21 |
22 | 'ses' => [
23 | 'key' => env('SES_KEY'),
24 | 'secret' => env('SES_SECRET'),
25 | 'region' => 'us-east-1',
26 | ],
27 |
28 | 'sparkpost' => [
29 | 'secret' => env('SPARKPOST_SECRET'),
30 | ],
31 |
32 | 'stripe' => [
33 | 'model' => App\User::class,
34 | 'key' => env('STRIPE_KEY'),
35 | 'secret' => env('STRIPE_SECRET'),
36 | ],
37 |
38 | ];
39 |
--------------------------------------------------------------------------------
/laravel/config/session.php:
--------------------------------------------------------------------------------
1 | env('SESSION_DRIVER', 'file'),
20 |
21 | /*
22 | |--------------------------------------------------------------------------
23 | | Session Lifetime
24 | |--------------------------------------------------------------------------
25 | |
26 | | Here you may specify the number of minutes that you wish the session
27 | | to be allowed to remain idle before it expires. If you want them
28 | | to immediately expire on the browser closing, set that option.
29 | |
30 | */
31 |
32 | 'lifetime' => 120,
33 |
34 | 'expire_on_close' => false,
35 |
36 | /*
37 | |--------------------------------------------------------------------------
38 | | Session Encryption
39 | |--------------------------------------------------------------------------
40 | |
41 | | This option allows you to easily specify that all of your session data
42 | | should be encrypted before it is stored. All encryption will be run
43 | | automatically by Laravel and you can use the Session like normal.
44 | |
45 | */
46 |
47 | 'encrypt' => false,
48 |
49 | /*
50 | |--------------------------------------------------------------------------
51 | | Session File Location
52 | |--------------------------------------------------------------------------
53 | |
54 | | When using the native session driver, we need a location where session
55 | | files may be stored. A default has been set for you but a different
56 | | location may be specified. This is only needed for file sessions.
57 | |
58 | */
59 |
60 | 'files' => storage_path('framework/sessions'),
61 |
62 | /*
63 | |--------------------------------------------------------------------------
64 | | Session Database Connection
65 | |--------------------------------------------------------------------------
66 | |
67 | | When using the "database" or "redis" session drivers, you may specify a
68 | | connection that should be used to manage these sessions. This should
69 | | correspond to a connection in your database configuration options.
70 | |
71 | */
72 |
73 | 'connection' => null,
74 |
75 | /*
76 | |--------------------------------------------------------------------------
77 | | Session Database Table
78 | |--------------------------------------------------------------------------
79 | |
80 | | When using the "database" session driver, you may specify the table we
81 | | should use to manage the sessions. Of course, a sensible default is
82 | | provided for you; however, you are free to change this as needed.
83 | |
84 | */
85 |
86 | 'table' => 'sessions',
87 |
88 | /*
89 | |--------------------------------------------------------------------------
90 | | Session Cache Store
91 | |--------------------------------------------------------------------------
92 | |
93 | | When using the "apc" or "memcached" session drivers, you may specify a
94 | | cache store that should be used for these sessions. This value must
95 | | correspond with one of the application's configured cache stores.
96 | |
97 | */
98 |
99 | 'store' => null,
100 |
101 | /*
102 | |--------------------------------------------------------------------------
103 | | Session Sweeping Lottery
104 | |--------------------------------------------------------------------------
105 | |
106 | | Some session drivers must manually sweep their storage location to get
107 | | rid of old sessions from storage. Here are the chances that it will
108 | | happen on a given request. By default, the odds are 2 out of 100.
109 | |
110 | */
111 |
112 | 'lottery' => [2, 100],
113 |
114 | /*
115 | |--------------------------------------------------------------------------
116 | | Session Cookie Name
117 | |--------------------------------------------------------------------------
118 | |
119 | | Here you may change the name of the cookie used to identify a session
120 | | instance by ID. The name specified here will get used every time a
121 | | new session cookie is created by the framework for every driver.
122 | |
123 | */
124 |
125 | 'cookie' => 'laravel_session',
126 |
127 | /*
128 | |--------------------------------------------------------------------------
129 | | Session Cookie Path
130 | |--------------------------------------------------------------------------
131 | |
132 | | The session cookie path determines the path for which the cookie will
133 | | be regarded as available. Typically, this will be the root path of
134 | | your application but you are free to change this when necessary.
135 | |
136 | */
137 |
138 | 'path' => '/',
139 |
140 | /*
141 | |--------------------------------------------------------------------------
142 | | Session Cookie Domain
143 | |--------------------------------------------------------------------------
144 | |
145 | | Here you may change the domain of the cookie used to identify a session
146 | | in your application. This will determine which domains the cookie is
147 | | available to in your application. A sensible default has been set.
148 | |
149 | */
150 |
151 | 'domain' => env('SESSION_DOMAIN', null),
152 |
153 | /*
154 | |--------------------------------------------------------------------------
155 | | HTTPS Only Cookies
156 | |--------------------------------------------------------------------------
157 | |
158 | | By setting this option to true, session cookies will only be sent back
159 | | to the server if the browser has a HTTPS connection. This will keep
160 | | the cookie from being sent to you if it can not be done securely.
161 | |
162 | */
163 |
164 | 'secure' => env('SESSION_SECURE_COOKIE', false),
165 |
166 | /*
167 | |--------------------------------------------------------------------------
168 | | HTTP Access Only
169 | |--------------------------------------------------------------------------
170 | |
171 | | Setting this value to true will prevent JavaScript from accessing the
172 | | value of the cookie and the cookie will only be accessible through
173 | | the HTTP protocol. You are free to modify this option if needed.
174 | |
175 | */
176 |
177 | 'http_only' => true,
178 |
179 | ];
180 |
--------------------------------------------------------------------------------
/laravel/config/view.php:
--------------------------------------------------------------------------------
1 | [
17 | resource_path('views'),
18 | ],
19 |
20 | /*
21 | |--------------------------------------------------------------------------
22 | | Compiled View Path
23 | |--------------------------------------------------------------------------
24 | |
25 | | This option determines where all the compiled Blade templates will be
26 | | stored for your application. Typically, this is within the storage
27 | | directory. However, as usual, you are free to change this value.
28 | |
29 | */
30 |
31 | 'compiled' => realpath(storage_path('framework/views')),
32 |
33 | ];
34 |
--------------------------------------------------------------------------------
/laravel/database/.gitignore:
--------------------------------------------------------------------------------
1 | *.sqlite
2 |
--------------------------------------------------------------------------------
/laravel/database/factories/ModelFactory.php:
--------------------------------------------------------------------------------
1 | define(App\User::class, function (Faker\Generator $faker) {
16 | static $password;
17 |
18 | return [
19 | 'name' => $faker->name,
20 | 'email' => $faker->unique()->safeEmail,
21 | 'password' => $password ?: $password = bcrypt('secret'),
22 | 'remember_token' => str_random(10),
23 | ];
24 | });
25 |
--------------------------------------------------------------------------------
/laravel/database/migrations/2014_10_12_000000_create_users_table.php:
--------------------------------------------------------------------------------
1 | increments('id');
18 | $table->string('name');
19 | $table->string('email')->unique()->nullable();
20 | $table->string('password')->nullable();
21 | $table->rememberToken();
22 | $table->timestamps();
23 | });
24 | }
25 |
26 | /**
27 | * Reverse the migrations.
28 | *
29 | * @return void
30 | */
31 | public function down()
32 | {
33 | Schema::dropIfExists('users');
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/laravel/database/migrations/2014_10_12_100000_create_password_resets_table.php:
--------------------------------------------------------------------------------
1 | string('email')->index();
18 | $table->string('token');
19 | $table->timestamp('created_at')->nullable();
20 | });
21 | }
22 |
23 | /**
24 | * Reverse the migrations.
25 | *
26 | * @return void
27 | */
28 | public function down()
29 | {
30 | Schema::dropIfExists('password_resets');
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/laravel/database/migrations/2017_06_17_162120_create_posts_table.php:
--------------------------------------------------------------------------------
1 | increments('id');
18 | $table->string('title');
19 | $table->text('body');
20 | $table->unsignedInteger('user_id');
21 | $table->timestamps();
22 |
23 |
24 | $table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
25 | });
26 | }
27 |
28 | /**
29 | * Reverse the migrations.
30 | *
31 | * @return void
32 | */
33 | public function down()
34 | {
35 | Schema::dropIfExists('posts');
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/laravel/database/migrations/2017_06_30_120120_create_social_accounts_table.php:
--------------------------------------------------------------------------------
1 | unsignedInteger('user_id');
18 | $table->string("provider");
19 | $table->string("provider_user_id");
20 | $table->timestamps();
21 |
22 | $table->unique(['user_id', 'provider']);
23 |
24 | $table->foreign("user_id")->references("id")->on("users")->onDelete('cascade');
25 | });
26 | }
27 |
28 | /**
29 | * Reverse the migrations.
30 | *
31 | * @return void
32 | */
33 | public function down()
34 | {
35 | Schema::dropIfExists('social_accounts');
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/laravel/database/seeds/DatabaseSeeder.php:
--------------------------------------------------------------------------------
1 | call(UsersTableSeeder::class);
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/laravel/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "private": true,
3 | "scripts": {
4 | "dev": "npm run development",
5 | "development": "cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
6 | "watch": "cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --watch --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
7 | "watch-poll": "npm run watch -- --watch-poll",
8 | "hot": "cross-env NODE_ENV=development node_modules/webpack-dev-server/bin/webpack-dev-server.js --inline --hot --config=node_modules/laravel-mix/setup/webpack.config.js",
9 | "prod": "npm run production",
10 | "production": "cross-env NODE_ENV=production node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js"
11 | },
12 | "devDependencies": {
13 | "axios": "^0.15.3",
14 | "bootstrap-sass": "^3.3.7",
15 | "cross-env": "^3.2.3",
16 | "jquery": "^3.1.1",
17 | "laravel-mix": "0.*",
18 | "lodash": "^4.17.4",
19 | "vue": "^2.1.10"
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/laravel/phpunit.xml:
--------------------------------------------------------------------------------
1 |
2 |
11 |
12 |
13 | ./tests/Feature
14 |
15 |
16 |
17 | ./tests/Unit
18 |
19 |
20 |
21 |
22 | ./app
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
--------------------------------------------------------------------------------
/laravel/public/.htaccess:
--------------------------------------------------------------------------------
1 |
2 |
3 | Options -MultiViews
4 |
5 |
6 | RewriteEngine On
7 |
8 | # Redirect Trailing Slashes If Not A Folder...
9 | RewriteCond %{REQUEST_FILENAME} !-d
10 | RewriteRule ^(.*)/$ /$1 [L,R=301]
11 |
12 | # Handle Front Controller...
13 | RewriteCond %{REQUEST_FILENAME} !-d
14 | RewriteCond %{REQUEST_FILENAME} !-f
15 | RewriteRule ^ index.php [L]
16 |
17 | # Handle Authorization Header
18 | RewriteCond %{HTTP:Authorization} .
19 | RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
20 |
21 |
--------------------------------------------------------------------------------
/laravel/public/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ProgrammationAndroid/Laravel-Passport-Android/305b910590216eb16c3d913c0c7a536ac05ea068/laravel/public/favicon.ico
--------------------------------------------------------------------------------
/laravel/public/index.php:
--------------------------------------------------------------------------------
1 |
8 | */
9 |
10 | /*
11 | |--------------------------------------------------------------------------
12 | | Register The Auto Loader
13 | |--------------------------------------------------------------------------
14 | |
15 | | Composer provides a convenient, automatically generated class loader for
16 | | our application. We just need to utilize it! We'll simply require it
17 | | into the script here so that we don't have to worry about manual
18 | | loading any of our classes later on. It feels great to relax.
19 | |
20 | */
21 |
22 | require __DIR__.'/../bootstrap/autoload.php';
23 |
24 | /*
25 | |--------------------------------------------------------------------------
26 | | Turn On The Lights
27 | |--------------------------------------------------------------------------
28 | |
29 | | We need to illuminate PHP development, so let us turn on the lights.
30 | | This bootstraps the framework and gets it ready for use, then it
31 | | will load up this application so that we can run it and send
32 | | the responses back to the browser and delight our users.
33 | |
34 | */
35 |
36 | $app = require_once __DIR__.'/../bootstrap/app.php';
37 |
38 | /*
39 | |--------------------------------------------------------------------------
40 | | Run The Application
41 | |--------------------------------------------------------------------------
42 | |
43 | | Once we have the application, we can handle the incoming request
44 | | through the kernel, and send the associated response back to
45 | | the client's browser allowing them to enjoy the creative
46 | | and wonderful application we have prepared for them.
47 | |
48 | */
49 |
50 | $kernel = $app->make(Illuminate\Contracts\Http\Kernel::class);
51 |
52 | $response = $kernel->handle(
53 | $request = Illuminate\Http\Request::capture()
54 | );
55 |
56 | $response->send();
57 |
58 | $kernel->terminate($request, $response);
59 |
--------------------------------------------------------------------------------
/laravel/public/robots.txt:
--------------------------------------------------------------------------------
1 | User-agent: *
2 | Disallow:
3 |
--------------------------------------------------------------------------------
/laravel/public/web.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/laravel/readme.md:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 | ## About Laravel
11 |
12 | Laravel is a web application framework with expressive, elegant syntax. We believe development must be an enjoyable and creative experience to be truly fulfilling. Laravel attempts to take the pain out of development by easing common tasks used in the majority of web projects, such as:
13 |
14 | - [Simple, fast routing engine](https://laravel.com/docs/routing).
15 | - [Powerful dependency injection container](https://laravel.com/docs/container).
16 | - Multiple back-ends for [session](https://laravel.com/docs/session) and [cache](https://laravel.com/docs/cache) storage.
17 | - Expressive, intuitive [database ORM](https://laravel.com/docs/eloquent).
18 | - Database agnostic [schema migrations](https://laravel.com/docs/migrations).
19 | - [Robust background job processing](https://laravel.com/docs/queues).
20 | - [Real-time event broadcasting](https://laravel.com/docs/broadcasting).
21 |
22 | Laravel is accessible, yet powerful, providing tools needed for large, robust applications. A superb combination of simplicity, elegance, and innovation give you tools you need to build any application with which you are tasked.
23 |
24 | ## Learning Laravel
25 |
26 | Laravel has the most extensive and thorough documentation and video tutorial library of any modern web application framework. The [Laravel documentation](https://laravel.com/docs) is thorough, complete, and makes it a breeze to get started learning the framework.
27 |
28 | If you're not in the mood to read, [Laracasts](https://laracasts.com) contains over 900 video tutorials on a range of topics including Laravel, modern PHP, unit testing, JavaScript, and more. Boost the skill level of yourself and your entire team by digging into our comprehensive video library.
29 |
30 | ## Laravel Sponsors
31 |
32 | We would like to extend our thanks to the following sponsors for helping fund on-going Laravel development. If you are interested in becoming a sponsor, please visit the Laravel [Patreon page](http://patreon.com/taylorotwell):
33 |
34 | - **[Vehikl](http://vehikl.com)**
35 | - **[Tighten Co.](https://tighten.co)**
36 | - **[British Software Development](https://www.britishsoftware.co)**
37 | - **[Styde](https://styde.net)**
38 | - [Fragrantica](https://www.fragrantica.com)
39 | - [SOFTonSOFA](https://softonsofa.com/)
40 |
41 | ## Contributing
42 |
43 | Thank you for considering contributing to the Laravel framework! The contribution guide can be found in the [Laravel documentation](http://laravel.com/docs/contributions).
44 |
45 | ## Security Vulnerabilities
46 |
47 | If you discover a security vulnerability within Laravel, please send an e-mail to Taylor Otwell at taylor@laravel.com. All security vulnerabilities will be promptly addressed.
48 |
49 | ## License
50 |
51 | The Laravel framework is open-sourced software licensed under the [MIT license](http://opensource.org/licenses/MIT).
52 |
--------------------------------------------------------------------------------
/laravel/resources/assets/js/app.js:
--------------------------------------------------------------------------------
1 |
2 | /**
3 | * First we will load all of this project's JavaScript dependencies which
4 | * includes Vue and other libraries. It is a great starting point when
5 | * building robust, powerful web applications using Vue and Laravel.
6 | */
7 |
8 | require('./bootstrap');
9 |
10 | window.Vue = require('vue');
11 |
12 | /**
13 | * Next, we will create a fresh Vue application instance and attach it to
14 | * the page. Then, you may begin adding components to this application
15 | * or customize the JavaScript scaffolding to fit your unique needs.
16 | */
17 |
18 | Vue.component('example', require('./components/Example.vue'));
19 |
20 | const app = new Vue({
21 | el: '#app'
22 | });
23 |
--------------------------------------------------------------------------------
/laravel/resources/assets/js/bootstrap.js:
--------------------------------------------------------------------------------
1 |
2 | window._ = require('lodash');
3 |
4 | /**
5 | * We'll load jQuery and the Bootstrap jQuery plugin which provides support
6 | * for JavaScript based Bootstrap features such as modals and tabs. This
7 | * code may be modified to fit the specific needs of your application.
8 | */
9 |
10 | try {
11 | window.$ = window.jQuery = require('jquery');
12 |
13 | require('bootstrap-sass');
14 | } catch (e) {}
15 |
16 | /**
17 | * We'll load the axios HTTP library which allows us to easily issue requests
18 | * to our Laravel back-end. This library automatically handles sending the
19 | * CSRF token as a header based on the value of the "XSRF" token cookie.
20 | */
21 |
22 | window.axios = require('axios');
23 |
24 | window.axios.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest';
25 |
26 | /**
27 | * Next we will register the CSRF Token as a common header with Axios so that
28 | * all outgoing HTTP requests automatically have it attached. This is just
29 | * a simple convenience so we don't have to attach every token manually.
30 | */
31 |
32 | let token = document.head.querySelector('meta[name="csrf-token"]');
33 |
34 | if (token) {
35 | window.axios.defaults.headers.common['X-CSRF-TOKEN'] = token.content;
36 | } else {
37 | console.error('CSRF token not found: https://laravel.com/docs/csrf#csrf-x-csrf-token');
38 | }
39 |
40 | /**
41 | * Echo exposes an expressive API for subscribing to channels and listening
42 | * for events that are broadcast by Laravel. Echo and event broadcasting
43 | * allows your team to easily build robust real-time web applications.
44 | */
45 |
46 | // import Echo from 'laravel-echo'
47 |
48 | // window.Pusher = require('pusher-js');
49 |
50 | // window.Echo = new Echo({
51 | // broadcaster: 'pusher',
52 | // key: 'your-pusher-key'
53 | // });
54 |
--------------------------------------------------------------------------------
/laravel/resources/assets/js/components/Example.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
Example Component
7 |
8 |
9 | I'm an example component!
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
24 |
--------------------------------------------------------------------------------
/laravel/resources/assets/sass/_variables.scss:
--------------------------------------------------------------------------------
1 |
2 | // Body
3 | $body-bg: #f5f8fa;
4 |
5 | // Borders
6 | $laravel-border-color: darken($body-bg, 10%);
7 | $list-group-border: $laravel-border-color;
8 | $navbar-default-border: $laravel-border-color;
9 | $panel-default-border: $laravel-border-color;
10 | $panel-inner-border: $laravel-border-color;
11 |
12 | // Brands
13 | $brand-primary: #3097D1;
14 | $brand-info: #8eb4cb;
15 | $brand-success: #2ab27b;
16 | $brand-warning: #cbb956;
17 | $brand-danger: #bf5329;
18 |
19 | // Typography
20 | $icon-font-path: "~bootstrap-sass/assets/fonts/bootstrap/";
21 | $font-family-sans-serif: "Raleway", sans-serif;
22 | $font-size-base: 14px;
23 | $line-height-base: 1.6;
24 | $text-color: #636b6f;
25 |
26 | // Navbar
27 | $navbar-default-bg: #fff;
28 |
29 | // Buttons
30 | $btn-default-color: $text-color;
31 |
32 | // Inputs
33 | $input-border: lighten($text-color, 40%);
34 | $input-border-focus: lighten($brand-primary, 25%);
35 | $input-color-placeholder: lighten($text-color, 30%);
36 |
37 | // Panels
38 | $panel-default-heading-bg: #fff;
39 |
--------------------------------------------------------------------------------
/laravel/resources/assets/sass/app.scss:
--------------------------------------------------------------------------------
1 |
2 | // Fonts
3 | @import url(https://fonts.googleapis.com/css?family=Raleway:300,400,600);
4 |
5 | // Variables
6 | @import "variables";
7 |
8 | // Bootstrap
9 | @import "node_modules/bootstrap-sass/assets/stylesheets/bootstrap";
10 |
--------------------------------------------------------------------------------
/laravel/resources/lang/en/auth.php:
--------------------------------------------------------------------------------
1 | 'These credentials do not match our records.',
17 | 'throttle' => 'Too many login attempts. Please try again in :seconds seconds.',
18 |
19 | ];
20 |
--------------------------------------------------------------------------------
/laravel/resources/lang/en/pagination.php:
--------------------------------------------------------------------------------
1 | '« Previous',
17 | 'next' => 'Next »',
18 |
19 | ];
20 |
--------------------------------------------------------------------------------
/laravel/resources/lang/en/passwords.php:
--------------------------------------------------------------------------------
1 | 'Passwords must be at least six characters and match the confirmation.',
17 | 'reset' => 'Your password has been reset!',
18 | 'sent' => 'We have e-mailed your password reset link!',
19 | 'token' => 'This password reset token is invalid.',
20 | 'user' => "We can't find a user with that e-mail address.",
21 |
22 | ];
23 |
--------------------------------------------------------------------------------
/laravel/resources/lang/en/validation.php:
--------------------------------------------------------------------------------
1 | 'The :attribute must be accepted.',
17 | 'active_url' => 'The :attribute is not a valid URL.',
18 | 'after' => 'The :attribute must be a date after :date.',
19 | 'after_or_equal' => 'The :attribute must be a date after or equal to :date.',
20 | 'alpha' => 'The :attribute may only contain letters.',
21 | 'alpha_dash' => 'The :attribute may only contain letters, numbers, and dashes.',
22 | 'alpha_num' => 'The :attribute may only contain letters and numbers.',
23 | 'array' => 'The :attribute must be an array.',
24 | 'before' => 'The :attribute must be a date before :date.',
25 | 'before_or_equal' => 'The :attribute must be a date before or equal to :date.',
26 | 'between' => [
27 | 'numeric' => 'The :attribute must be between :min and :max.',
28 | 'file' => 'The :attribute must be between :min and :max kilobytes.',
29 | 'string' => 'The :attribute must be between :min and :max characters.',
30 | 'array' => 'The :attribute must have between :min and :max items.',
31 | ],
32 | 'boolean' => 'The :attribute field must be true or false.',
33 | 'confirmed' => 'The :attribute confirmation does not match.',
34 | 'date' => 'The :attribute is not a valid date.',
35 | 'date_format' => 'The :attribute does not match the format :format.',
36 | 'different' => 'The :attribute and :other must be different.',
37 | 'digits' => 'The :attribute must be :digits digits.',
38 | 'digits_between' => 'The :attribute must be between :min and :max digits.',
39 | 'dimensions' => 'The :attribute has invalid image dimensions.',
40 | 'distinct' => 'The :attribute field has a duplicate value.',
41 | 'email' => 'The :attribute must be a valid email address.',
42 | 'exists' => 'The selected :attribute is invalid.',
43 | 'file' => 'The :attribute must be a file.',
44 | 'filled' => 'The :attribute field must have a value.',
45 | 'image' => 'The :attribute must be an image.',
46 | 'in' => 'The selected :attribute is invalid.',
47 | 'in_array' => 'The :attribute field does not exist in :other.',
48 | 'integer' => 'The :attribute must be an integer.',
49 | 'ip' => 'The :attribute must be a valid IP address.',
50 | 'ipv4' => 'The :attribute must be a valid IPv4 address.',
51 | 'ipv6' => 'The :attribute must be a valid IPv6 address.',
52 | 'json' => 'The :attribute must be a valid JSON string.',
53 | 'max' => [
54 | 'numeric' => 'The :attribute may not be greater than :max.',
55 | 'file' => 'The :attribute may not be greater than :max kilobytes.',
56 | 'string' => 'The :attribute may not be greater than :max characters.',
57 | 'array' => 'The :attribute may not have more than :max items.',
58 | ],
59 | 'mimes' => 'The :attribute must be a file of type: :values.',
60 | 'mimetypes' => 'The :attribute must be a file of type: :values.',
61 | 'min' => [
62 | 'numeric' => 'The :attribute must be at least :min.',
63 | 'file' => 'The :attribute must be at least :min kilobytes.',
64 | 'string' => 'The :attribute must be at least :min characters.',
65 | 'array' => 'The :attribute must have at least :min items.',
66 | ],
67 | 'not_in' => 'The selected :attribute is invalid.',
68 | 'numeric' => 'The :attribute must be a number.',
69 | 'present' => 'The :attribute field must be present.',
70 | 'regex' => 'The :attribute format is invalid.',
71 | 'required' => 'The :attribute field is required.',
72 | 'required_if' => 'The :attribute field is required when :other is :value.',
73 | 'required_unless' => 'The :attribute field is required unless :other is in :values.',
74 | 'required_with' => 'The :attribute field is required when :values is present.',
75 | 'required_with_all' => 'The :attribute field is required when :values is present.',
76 | 'required_without' => 'The :attribute field is required when :values is not present.',
77 | 'required_without_all' => 'The :attribute field is required when none of :values are present.',
78 | 'same' => 'The :attribute and :other must match.',
79 | 'size' => [
80 | 'numeric' => 'The :attribute must be :size.',
81 | 'file' => 'The :attribute must be :size kilobytes.',
82 | 'string' => 'The :attribute must be :size characters.',
83 | 'array' => 'The :attribute must contain :size items.',
84 | ],
85 | 'string' => 'The :attribute must be a string.',
86 | 'timezone' => 'The :attribute must be a valid zone.',
87 | 'unique' => 'The :attribute has already been taken.',
88 | 'uploaded' => 'The :attribute failed to upload.',
89 | 'url' => 'The :attribute format is invalid.',
90 |
91 | /*
92 | |--------------------------------------------------------------------------
93 | | Custom Validation Language Lines
94 | |--------------------------------------------------------------------------
95 | |
96 | | Here you may specify custom validation messages for attributes using the
97 | | convention "attribute.rule" to name the lines. This makes it quick to
98 | | specify a specific custom language line for a given attribute rule.
99 | |
100 | */
101 |
102 | 'custom' => [
103 | 'attribute-name' => [
104 | 'rule-name' => 'custom-message',
105 | ],
106 | ],
107 |
108 | /*
109 | |--------------------------------------------------------------------------
110 | | Custom Validation Attributes
111 | |--------------------------------------------------------------------------
112 | |
113 | | The following language lines are used to swap attribute place-holders
114 | | with something more reader friendly such as E-Mail Address instead
115 | | of "email". This simply helps us make messages a little cleaner.
116 | |
117 | */
118 |
119 | 'attributes' => [],
120 |
121 | ];
122 |
--------------------------------------------------------------------------------
/laravel/resources/views/welcome.blade.php:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | Laravel
9 |
10 |
11 |
12 |
13 |
14 |
66 |
67 |
68 |