@@ -33,7 +33,6 @@ LocalComponents.Page {
33 backButtonText: i18n.tr("Cancel")
33 backButtonText: i18n.tr("Cancel")
35 property alias password: passwordField.text
35 property alias password: passwordField.text
36− readonly property int passwordScore: scorePassword(password)
37 property bool confirmPhase: false
36 property bool confirmPhase: false
39 // If we are entering this page, clear any saved password and get focus
38 // If we are entering this page, clear any saved password and get focus
@@ -71,39 +70,10 @@ LocalComponents.Page {
71 if (!!text) {
70 if (!!text) {
72 infoLabel.text = text
71 infoLabel.text = text
74− infoLabel.text = i18n.tr("Enter at least 4 characters")
73+ infoLabel.text = i18n.tr("Enter at least 6 characters")
78− function scorePassword(pass) {
83− // award every unique letter until 5 repetitions
84− var letters = Object();
85− for (var i=0; i<pass.length; i++) {
86− letters[pass[i]] = (letters[pass[i]] || 0) + 1;
87− score += 5.0 / letters[pass[i]];
90− // bonus points for mixing it up
92− digits: /\d/.test(pass),
93− lower: /[a-z]/.test(pass),
94− upper: /[A-Z]/.test(pass),
95− nonWords: /\W/.test(pass),
98− var variationCount = 0;
99− for (var check in variations) {
100− variationCount += (variations[check] === true) ? 1 : 0;
102− score += (variationCount - 1) * 10;
104− return parseInt(score);
108 id: column
78 id: column
109 anchors.fill: content
79 anchors.fill: content
@@ -139,59 +109,21 @@ LocalComponents.Page {
143− id: passwordStrengthMeter
147− top: passwordField.bottom
148− topMargin: units.gu(1)
153− if (passwordScore > 80)
155− if (passwordScore > 60)
157− if (passwordScore >= 30)
162− visible: password.length > 0
112+ // password meter
163− }
113+ LocalComponents.PasswordMeter {
166− id: passwordStrengthInfo
168− left: parent.left
115+ anchors.left: parent.left
169− right: parent.right
116+ anchors.right: parent.right
170− top: passwordStrengthMeter.bottom
117+ anchors.top: passwordField.bottom
171− topMargin: units.gu(1)
118+ anchors.topMargin: units.gu(1)
172− }
119+ password: passwordField.text
175− if (passwordScore > 80)
176− return i18n.tr("Strong password");
177− else if (passwordScore > 60)
178− return i18n.tr("Medium password")
179− if (passwordScore >= 30)
180− return i18n.tr("Weak password");
182− return i18n.tr("Very weak password");
186− font.weight: Font.Light
187− visible: password.length > 0
191 Component {
123 Component {
192 id: forwardButton
124 id: forwardButton
193 LocalComponents.StackButton {
125 LocalComponents.StackButton {
194− enabled: confirmPhase ? password === root.password : password.length >= 4 // TODO set more sensible restrictions for the length?
126+ enabled: confirmPhase ? password === root.password : password.length > 5 // TODO set more sensible restrictions for the length?
195 text: i18n.tr("OK")
127 text: i18n.tr("OK")
196 onClicked: {
128 onClicked: {
197 if (confirmPhase) {
129 if (confirmPhase) {