我将数据存储在 Cloud Firestore 数据库中。我的应用程序中的用户不需要创建帐户来获取数据,他们也可以在不登录的情况下写入数据。
谷歌每隔几天就会提醒我,我的数据库不安全,任何人都可以滥用。如何在不访问 Auth 变量的情况下改进它?
我的火力点规则
service cloud.firestore {
match /databases/{database}/documents {
match /{document=**} {
allow read, write;
}
}
}
Run Code Online (Sandbox Code Playgroud)
有没有办法在不使用身份验证的情况下使我的数据库更安全?
我的应用程序的逻辑:
我的数据库包含姓氏及其起源。如果有人输入姓名,他会从数据库中取回原名。示例:“Doe”->“墨西哥”。如果我的数据库中不存在姓氏,我会调用 API 并将值保存到我的数据库中。每个用户都需要读写权限。
我能在这里做什么?
一个简单但非常复杂的问题:为 Flutter 相机添加点击对焦功能的最佳方法是什么?
我在整个万维网上搜索了有关优雅解决方案的内容,但一无所获。
你有想法吗?
要允许访问管理路由,我必须检查两件事:
管理卫士
import {ActivatedRouteSnapshot, CanActivate, Router,
RouterStateSnapshot} from '@angular/router';
import {Observable} from 'rxjs/Observable';
import {AngularFireAuth} from 'angularfire2/auth';
import {Injectable} from '@angular/core';
import {DbActionsService} from '../services/db-actions.service';
import {AuthService} from '../services/auth.service';
import 'rxjs/add/operator/map';
@Injectable()
export class AdminGuard implements CanActivate {
constructor(private afAuth: AngularFireAuth, private router: Router, private dbAction: DbActionsService, private authService : AuthService) {}
canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<boolean> | boolean {
if (this.afAuth.auth.currentUser) {
return this.dbAction.getUserProfileData(this.afAuth.auth.currentUser.email).map((user) => {
if (user[0].admin) {
return true;
} else {
this.router.navigate(['/']); …
Run Code Online (Sandbox Code Playgroud) 我正在过滤整个 DOM 以用其他字符串替换某些字符串。
为此我编写了以下代码:
$('body :not(script)').contents().filter(function() {
return this.nodeType === 3;
}).replaceWith(function() {
return this.nodeValue.replace('T 0','T 0');
});
Run Code Online (Sandbox Code Playgroud)
如何排除某些区域?例如,我希望.example
不考虑具有类的 DIV。
我尝试了以下方法:
$('body :not(script):not(.example)').contents().filter(function() {
return this.nodeType === 3;
}).replaceWith(function() {
return this.nodeValue.replace('T 0','T 0');
});
Run Code Online (Sandbox Code Playgroud)
为什么这似乎不起作用?
我使用 Firebase Cloud Messaging、Cloud Functions 和 Flutter 作为框架发送 FCM 推送通知。我花了 3 个小时寻找一个解决方案来接收带有翻译的后台通知。我想以设备语言显示翻译。
我发现的是像titleLocKey
和 之类的参数bodyLocKey
,但我找不到任何使用这些参数的方法。在我的项目或服务器环境中的哪个位置我必须包含此变量?
我像这样触发通知:
// Push Notification
const payload: admin.messaging.MessagingPayload = {
notification: {
title: "New User",
body: "A new user entered your platform",
badge: "1",
}
}
fcm.sendToDevice(userToken, payload);
Run Code Online (Sandbox Code Playgroud)
你有什么主意吗?
firebase flutter google-cloud-functions firebase-cloud-messaging
目前,我的应用程序中的get
Flutter 包 ( https://pub.dev/packages/get ) 和以下状态场景存在许多问题:
例如我有一个 GetxController UserController
。我需要在不同的小部件中使用此控制器,因此我在第一个小部件中使用它进行初始化Get.put()
,对于其他子小部件,我将使用Get.find()
. 这样可行。
但是:我有一些小部件,有时在控制器初始化之前加载,有时在控制器初始化之后加载。所以我得到了很多"UsersController" not found
错误。也许这个问题有一些解决方法?
我尝试对这样的数组进行排序...
...在 Angular2 中。
成分
this.streetDetailRef = this.afDatabase.list('data/users/' + this.currentUserID + '/territory/' + this.sStreet.parentKey + '/' + this.sStreet.key + '/houseNumbers/');
this.streetDetailData = this.streetDetailRef.snapshotChanges().map(changes => {
return changes.map(c => ({ key: c.payload.key, ...c.payload.val() })).sort();
});
Run Code Online (Sandbox Code Playgroud)
我认为的循环
<ion-item-sliding *ngFor="let house of streetDetailData | async | orderBy: 'number':false" #slidingItem>
<strong>{{ house.number }}</strong> ...
Run Code Online (Sandbox Code Playgroud)
'number'
在这种情况下是没有字母的干净数字。我将这封信存储在一个单独的 firebase 条目中。但如果需要,肯定可以将它们存储在同一个中。
附加信息:我正在使用 VadimDez 的 ngx-orderBy-pipe:https : //github.com/VadimDez/ngx-order-pipe
我正在尝试将加载微调器集成到按钮中。这也很有效。问题:如果我点击一个按钮,微调器会响应每一个额外的按钮。
我该如何纠正?
我的代码:
<button ion-button block (click)="loading = true">
<ion-spinner class="whiteSpinner" item-left *ngIf="loading" name="bubbles"></ion-spinner>
Buy now - 1,49€
</button>
Run Code Online (Sandbox Code Playgroud)
其他按钮一样...
图像向您展示我的意思:
我尝试下载并仅显示实时数据库中的特定数据.我有以下代码:
getUserPlatformIos() {
this.dataRef = this.afDatabase.list('data/users', ref => ref.orderByChild('meta/platform').equalTo('ios'));
this.data = this.dataRef.snapshotChanges().map(changes => {
return changes.map(c => ({ key: c.payload.key, ...c.payload.val() }));
});
return this.data;
}
Run Code Online (Sandbox Code Playgroud)
为什么firebase会在我之前查询时下载整个数据库?这导致非常长的加载时间和大量下载的数据....
firebase ionic-framework firebase-realtime-database angularfire2 ionic3
firebase ×5
angular ×3
angularfire2 ×3
flutter ×3
ionic3 ×2
typescript ×2
angular5 ×1
dart ×1
flutter-getx ×1
ionic2 ×1
javascript ×1
jquery ×1