@@ -127,14 +127,15 @@ void LoginForm::initialize()
127
127
ui->userInput ->completer ()->setCompletionMode (QCompleter::InlineCompletion);
128
128
}
129
129
130
- QString user = Cache ().getLastUser ();
130
+ QString tmp = Cache ().getLastUser ();
131
+ QString user = getShortUsername (tmp);
131
132
132
133
if (user.isEmpty () || user.isNull ()) {
133
134
user = m_Greeter.selectUserHint ();
134
135
ui->pushButton_right ->hide ();
135
136
currentSessionStr = m_Greeter.defaultSessionHint ();
136
137
}else {
137
- currentSessionStr = Cache ().getLastSession (user);
138
+ currentSessionStr = Cache ().getLastSession (getShortUsername ( user) );
138
139
}
139
140
140
141
@@ -377,9 +378,9 @@ void LoginForm::authenticationComplete()
377
378
378
379
needPasswordChange = 0 ;
379
380
380
- addUsertoCache (lastuser);
381
- Cache ().setLastUser (lastuser);
382
- Cache ().setLastSession (lastuser, currentSessionStr);
381
+ addUsertoCache (getShortUsername ( lastuser) );
382
+ Cache ().setLastUser (getShortUsername ( lastuser) );
383
+ Cache ().setLastSession (getShortUsername ( lastuser) , currentSessionStr);
383
384
Cache ().sync ();
384
385
385
386
qWarning () << " Start session : " << currentSessionStr;
@@ -559,11 +560,13 @@ void LoginForm::initializeUserList(){
559
560
560
561
total_user_count = 0 ;
561
562
animationprogress = false ;
563
+ QString tmp;
562
564
563
565
564
566
565
567
for (int i = 0 ; i < Settings ().cachedusercount (); i++){
566
- userList[i] = Cache ().getLastUserfromIndex (i);
568
+ tmp = Cache ().getLastUserfromIndex (i);
569
+ userList[i] = getShortUsername (tmp);
567
570
568
571
if (!userList[i].isNull () && !userList[i].isEmpty () && userList[i].length () > 1 )
569
572
total_user_count++;
@@ -584,7 +587,7 @@ void LoginForm::initializeUserList(){
584
587
qInfo () << (QString::number (total_user_count) + " users found for last users cache" );
585
588
586
589
587
- currentSessionStr = Cache ().getLastSession ( userList[0 ]);
590
+ currentSessionStr = Cache ().getLastSession ( getShortUsername ( userList[0 ]) );
588
591
qInfo () << " currentSessionStr: " << currentSessionStr;
589
592
590
593
total_user_count++;
@@ -661,7 +664,6 @@ void LoginForm::addUsertoCache(QString user_name){
661
664
if (userList[0 ].isNull () || userList[0 ].isEmpty () || userList[0 ].length () < 2 ){
662
665
userList[i].clear ();
663
666
}
664
-
665
667
if (userList[i].compare (user_name) == 0 )
666
668
userList[i].clear ();
667
669
@@ -720,7 +722,7 @@ void LoginForm::addUsertoCache(QString user_name){
720
722
721
723
for (i = 0 ; i < Settings ().cachedusercount (); i++){
722
724
if (!userList[i].isNull () && !userList[i].isEmpty () && userList[i].length () > 2 )
723
- Cache ().setLastUsertoIndex (userList[i], i);
725
+ Cache ().setLastUsertoIndex (getShortUsername ( userList[i]) , i);
724
726
else
725
727
Cache ().setLastUsertoIndex (" " , i);
726
728
@@ -1294,7 +1296,7 @@ void LoginForm::LoginTimerFinished(){
1294
1296
qInfo () << " Login start for " + userid;
1295
1297
1296
1298
qInfo () << " User name is sending" ;
1297
- m_Greeter.authenticate (userid. trimmed ( ));
1299
+ m_Greeter.authenticate (fixUserName (userid ));
1298
1300
// addUsertoCache(userid.trimmed());//todo delete
1299
1301
// Cache().setLastUser(userid.trimmed());//todo delete
1300
1302
@@ -1612,7 +1614,7 @@ void LoginForm::passwordResetTimerFinished(){
1612
1614
userx = toolButtons[(lastuserindex+ 1 ) % 3 ]->text ();
1613
1615
}
1614
1616
1615
- m_Greeter.authenticate (userx);
1617
+ m_Greeter.authenticate (fixUserName ( userx) );
1616
1618
resetTimerState = 2 ;
1617
1619
break ;
1618
1620
@@ -2560,3 +2562,54 @@ void LoginForm::on_userInput_textEdited(const QString &arg1)
2560
2562
emit resetHideTimer ();
2561
2563
justshowed = false ;
2562
2564
}
2565
+
2566
+
2567
+
2568
+ QString LoginForm::fixUserName (QString &username){
2569
+
2570
+ QString newname, tmpname;
2571
+ int offset;
2572
+ QString realm = getUserRealm (username);
2573
+
2574
+ offset = username.indexOf (realm.toLower ());
2575
+
2576
+ if (offset < 0 )
2577
+ offset = username.indexOf (realm.toUpper ());
2578
+
2579
+ if (offset > 1 ){
2580
+ tmpname = username.mid (0 , offset - 1 );
2581
+ }else {
2582
+ tmpname = username;
2583
+ }
2584
+
2585
+ if (realm.length () > 2 ){
2586
+ newname = tmpname.trimmed () + " @" + realm;
2587
+ }else {
2588
+ newname = tmpname;
2589
+ }
2590
+
2591
+ return newname;
2592
+ }
2593
+
2594
+ QString LoginForm::getShortUsername (QString &username){
2595
+
2596
+ QString newname, tmpname;
2597
+ int offset;
2598
+ QString realm = getUserRealm (username);
2599
+
2600
+ offset = username.indexOf (realm.toLower ());
2601
+
2602
+ if (offset < 0 )
2603
+ offset = username.indexOf (realm.toUpper ());
2604
+
2605
+ if (offset > 1 ){
2606
+ tmpname = username.mid (0 , offset - 1 );
2607
+ }else {
2608
+ tmpname = username;
2609
+ }
2610
+
2611
+
2612
+ return tmpname;
2613
+
2614
+ }
2615
+
0 commit comments