【发布时间】:2017-07-17 09:28:45
【问题描述】:
我正在创建一个包含用户可以加入和创建的频道的房间。但是,我希望用户可以选择为他们创建的频道添加密码。现在我想知道是否可以在 Firebase 中添加一个加密的密码。当然,一种选择是将密码上传到 Firebase 中的字符串中,就像普通值一样,但这对任何人都是可读的(因为 .read 规则说的是真的)。这样,任何人都可以看到我不想要的密码。所以我的问题是:这可能吗,如果是的话:如何?下面是一些可能会有所帮助的代码。
创建通道IBAction函数:
@IBAction func createChannel(_ sender: AnyObject) {
if let name = newChannelTextField?.text {
let newChannelRef = channelRef.childByAutoId()
let channelItem = [
"name": name
]
newChannelRef.setValue(channelItem)
}
}
Channel.swift:
internal class Channel {
internal let id: String
internal let name: String
init(id: String, name: String) {
self.id = id
self.name = name
}
}
是否选择了单元格功能:
override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath)
{
if indexPath.section == Section.currentChannelsSection.rawValue
{
if searchController.isActive && searchController.searchBar.text != ""
{
let channel = filteredChannels[(indexPath as NSIndexPath).row]
sendStatisticsToChannel(channel: channel)
}
else
{
let channel = channels[(indexPath as NSIndexPath).row]
sendStatisticsToChannel(channel: channel)
}
}
}
【问题讨论】:
标签: swift firebase firebase-realtime-database firebase-authentication firebase-security